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
300
Summary Row Problems
posted

 I have a problem with my summary row. I wanted to calculate an average of column on my own with a formula and round it with 0 decimals. Therefore I use the following piece of code:

                            band.Summaries.Add(GUI_Res.SummaryKeyIntervalAvg,
                                                            SummaryType.Formula,
                                                            band.Columns[14],
                                                            SummaryPosition.UseSummaryPositionColumn);
                            UltraGridColumn col = band.Columns[14];

                            string formula = "round(average(if(isblank( [" + col.ToString() + "]) , 0 , [" + col.ToString() + "] )),0)";

                            band.Summaries[GUI_Res.SummaryKeyIntervalAvg].Formula = formula;
                            band.Summaries[GUI_Res.SummaryKeyIntervalAvg].DisplayFormat = "Avg = {0}";

If I change the SummaryType to Average, a value is shown. With the code above, I only see the Caption "Avg =".

 

Am I doing anything wrong here or what could be the problem? Is it possible to use SummaryType.Average and format the output (e.g. no. of decimals)?

 

I am using v.7.2 

Parents
  • 469350
    Verified Answer
    Offline posted

    Hi,

        The formula you have here doesn't make sense. the Average function takes a list of values - a range reference. You are passing in the results of the if function which returns a boolean (a single value). So you are not getting the average of anything useful.

        It looks to me like you want to take the average of the column but you want to ignore blank values. There's no way to do that with a formula or using the Average summary. The only way to ignore certain rows in the calculation would be to create your own custom SummaryCalculator (using the SummaryType.Custom.  

Reply Children