cancel
Showing results for 
Search instead for 
Did you mean: 

Displaying 0 for a running total when the condition wasn't met

iamsc
Discoverer
0 Kudos

I have a running total on my report that uses a formula to decide whether to evaluate which fields to total. In some cases, the condition is never met within the group. I have the running total displaying in a field. However Crystal won't display 0 in the field, it just hides the field. How do I get it to display 0?

Also, I need this to use this running total in a formula. In my formula I have:

 If {#runningTotal} > 0 then "do a barrel roll :D"

But when I try to display this formula that has #runningTotal in it, it just shows a blank field. It works fine if the condition is met and has a number to use.

Accepted Solutions (1)

Accepted Solutions (1)

iamsc
Discoverer
0 Kudos

Thank you! That got me there. I didn't think to just check if the var was null.

Instead of

If {#runningTotal} > 0

I can use

If ISNULL({#runningTotal})

Answers (1)

Answers (1)

DellSC
Active Contributor

The problem is that the result of the running total that you're dealing with is actually null. So, there are a couple of things you can do.

1. Automatically account for nulls by going to File >> Options >> Reporting tab and checking both "Convert Other NULL values to Default" and "Convert Database Null values to Default". This is the easiest way to handle the issue.

2. Manually handle the null values. This would mean using a formula in the running total instead of the field:

{@Value for Running Total}

if <condition from running total> then {MyTable.MyField} else 0

You can then take the condition off the running total, since it's in the formula here. The result will be 0 if the condition is not met.

-Dell