Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
225
Computing average summary using a formula
posted

Hello,

my goal is to compute average value for a grid column, ignoring BOTH records with null values AND 0 values.

I read "HOWTO:How to calculate the average in a WinGrid footer summary if there are null values in the column" (Knowledge Base Article: KB010019), but I have not been able to put both conditions together. Following the KB sample, I have tried something like:

average(if( isblank([Column 1]) OR [Column 1]=0) , 0 , [Column 1] )), using nearly each kind of combinations with parenthesis, single quotes, double quotes...

and something like:

average( if (isblank( if([Column 1]=0, '', [Column 1]) ) , 0 , [Column 1] )),

with no success.

The only way so far to get my result is to add a calculated column "Column 2" with a formula that replaces 0 values with void values, and computing average on that column ignoring null values, in the following way:

            e.Layout.Bands[0].Columns["Column 2"].Formula = "if([Column 1]=0,'',[Column 1])";
.....

            e.Layout.Bands[0].Summaries["Summary"].Formula = "average(if( isblank([Column 2]) , 0 , [Column 2] ))";

The question is: Is there a 'clean' way to achieve the desired result by a single formula, without using additional columns?

Thank you in advance,

Franz



 

Parents Reply Children