Print Page | Close Window

"COUNTIF"? Count instances of a value on a report?

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=7349
Printed Date: 18 May 2024 at 4:06am


Topic: "COUNTIF"? Count instances of a value on a report?
Posted By: Jon K
Subject: "COUNTIF"? Count instances of a value on a report?
Date Posted: 12 Aug 2009 at 5:46am
Hello all - nice forum!  Now I can find help with all my Crystal Reports questions.

I have a report that we are setting various fields to "ACT" "OBS" or "UNK" based on an integer in a certain field using a series of if then else formulas.

I have a user that wants to be able to count how many times in a specific query "ACT" shows up and have it placed in the footer.  Basically a sum based on the presence of "ACT".

What is the best way to do this?



Replies:
Posted By: lockwelle
Date Posted: 12 Aug 2009 at 6:16am
DBlank will do it differently than me, he tends to make a formula that will return a 1 or 0 and then sum it up, but I would use shared variables.
 
since this sounds like it will only be used once per report, only 2 formulas needed, and one already exists.
 
modify the existing formula that selects the ACT to display with
shared numbervar ACT;
 
for the else section that will display ACT:
else (
 "ACT";
 ACT:=ACT + 1;
)
 
now in the footer all you need a formula to display your variable:
shared numbervar ACT
 
HTH


Posted By: Jon K
Date Posted: 12 Aug 2009 at 7:43am
Excellent - I think I understand.  I will mention both methods.  I think for this end user it might be easier for him to return 1/0 and sum that, but I like your method better if I had to choose.  I will pass this along!

This looks like a great resource!



Print Page | Close Window