grimmig
grimmig

Reputation: 1421

Count number of Boolean In Crystal Reports

I've got a report that contains a column with boolean value.

Now I want to create a running total that counts the number of rows in which the value is true.

If I create a running total over that column I can only choose aggregates like "maximum" or "number of values" but not "sum" as I can with integers. Is there something like a cast operator with which I can convert the boolean field to a number so that the usual integer operators work?

Upvotes: 3

Views: 3751

Answers (1)

Ryan
Ryan

Reputation: 7287

You can do this by creating a Running Total and then selecting "count" as your aggregate function with one small addition; When you're in the "Edit Running Total Field" window, go to the "Evaluate" section and select "Use a formula". Simply enter your boolean field as the formula.

This will count each row that has a True for your boolean field.

Alternatively, if you really wanted to manipulate the boolean field as numeric, then you could just create a simple formula that converts from boolean to numeric:

if {boolfield} then 1 else 0 or cdbl({boolfield})

Upvotes: 5

Related Questions