• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3620
  • Last Modified:

Crystal Reports - Countif

How to countIf a field = to a certain criteria.
My questions (Crystal 9).  I am working on a report where I have to count the number of instances in a fields.  Example: Field A; total of number X's, Total number of Y's in that field, Total numer of Z's.  I have tried using the countif FieldA = "X", which works in Excel but evidently not in Crystal.  
-Do I have to group first?
-If so, I do not want the group to show on the report, just the group totals.
-Is there a code such as "countif" that I can use instead of grouping?
1 Solution
You need to create a formula first, and then summarize the formula.

So your formula would look something like this:

if {table.field} = "X"
then 1
else 0

You can then go to the Insert menu, choose Summary.
Pick this formula, then sum, then the location where you want to summary to be.
Repeat for each different condition you need to summarize.
syhctlAuthor Commented:
Thanks so much..

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now