Crystal - Count if with multiple qualifiers

I want to count Column A if Columns B and C meet a certain criteria:

Col A     Col  B    Col C
1            True     Original
2            True     Original
3            null       Original
4            True     Canceled

The result I am looking for would be a sum of 2 from the above data.

I think the formula I came up with is close but I keep getting a "The Keyword 'Then' is missing" Here is what I came up:

if ({tblCases.IsComplete} = true) and
if ({tblCases.CaseStatus} = 'original')) then Count ({tblCases.NumberCases})
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

We need to be quite clear about what you want here.

Count() counts 1 for each item, irrespective of the item's value.
If you want to add up the values then you need Sum not Count.

But it looks like you should be using a Running Totals field for this whichever you want.

Seelect the field to summatrise as ColA.
Select Sum or Count whichever it is you want.
In the 'Evaluate when' you select Use formula and in the formul you put:

({tblCases.IsComplete} = true) and ({tblCases.CaseStatus} = 'original'))

If you want one total for the whole report you set Reset to Never.
Put the field in your report footer.
dsabineAuthor Commented:
OK.....then to be clear, I need to SUM on the total number of cases not a count. I need to:

Count tblCases.NumberCases
if tblCases.CaseStatus = 'original and tblCases.IsComplete
As I said , use a running totals field as I described.
I think Peter's got you pretty well covered to get your count.  If you're trying to get a count of the records where certain conditions are true, then, as he said, you can use a running total to do a count, but only when your conditions are met.

 FWIW, the error from your original formula was because of the "and if" between your two conditions.  That should have just been "and", without the "if".

 if a and b then c      // Valid
 if a and if b then c   // Not valid

 Just to be clear, the formula still wouldn't have given you the count you wanted.  Count () gives you a final count every time you use it, as opposed to adding 1 to a count every time you use it, which seemed to be what you were expecting.

That should work.

You could also use a formula like

if ({tblCases.IsComplete} = true) and  ({tblCases.CaseStatus} = 'original')) then

Then simply add it up with a summary function.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.