Click to See Complete Forum and Search --> : Calculating the average of running total fields: empty result
Stijn
March 24th, 2004, 05:38 AM
I want to calculate the average of 12 running total fields. Some totals fields are empty.
If I calculate the average when one of the total fields is empty, the result is also empty.
The average is only calculated when the 12 running total fields aren't empty.
Does someone knows what I have to do?
malleyo
March 24th, 2004, 09:35 AM
Instead of an empty field, could you populate it with a 0? Or when you do your average, maybe you could use some kind of If statement to change Empty fields into zeros (If value is NULL Then value = 0). I don't know what the correct syntax for that would be in Crystal Reports though.
Stijn
March 25th, 2004, 02:38 AM
Thanks for the advice. I found a statement which replaces the empty fields with a zero. It's like this:
average (
[if not isnull({#field1}) then ({#field1}) else 0,
if not isnull({#field2}) then ({#field2}) else 0,
if not isnull({#field3}) then ({#field3}) else 0,
...]
)
codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved.