Creating a formula for a conditional count on two unique values in Crystal Reports

I'm using the following formula successfully with a summary (count) on that formula to count unique values in a field:
if {table.field} = 1   then '1'    else '0'

I'm now trying to count two unique values and cannot get the summary count to work:
if {table.field} = 1 OR  {table.field} = 2  then '1'    else '0'

It does not combine the two values in the count.
Gary DemosAsked:
Who is Participating?
 
mlmccConnect With a Mentor Commented:
You could also do it this way

if {table.field} = 1 OR  {table.field} = 2  then
    1
Else
    0

Then do a SUM instead of a count

mlmcc
0
 
Pawan KumarDatabase ExpertCommented:
Is your count coming incorrect?
0
 
Gary DemosAuthor Commented:
Oh it is working after I changed the ELSE {@NULL} and did a COUNT instead of DISTINCT COUNT in the summary. Sorry for the  confusion!
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
Pawan KumarConnect With a Mentor Database ExpertCommented:
Great.. i also thought that was the issues. Great .. :)

cheers.

Try this also  , do not include else part.

if {table.field} = 1 OR  {table.field} = 2  then '1'
0
 
Gary DemosAuthor Commented:
That's a clever idea!
0
 
mlmccCommented:
No need to worry about distinct count or the '0' values being counted.

mlmcc
0
 
Gary DemosAuthor Commented:
Great help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.