Totals - ignore NULL values

Stimulsoft Reports.NET discussion
Post Reply
mmmmmm
Posts: 27
Joined: Mon Oct 24, 2011 5:51 am

Totals - ignore NULL values

Post by mmmmmm »

Hello,

I have data table with some NULL in some of the rows.
I am trying to compute Totals.Min value over a column, but I am getting a 0 as the min and I suppose that this is because of the NULL values.

Is there a way to exlcude the NULLs from computation of the MIN. Such as there is for SumIf and CountIf?
The same question goes for Avg I guess.

Thank you!
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Totals - ignore NULL values

Post by Alex K. »

Hello,

Please check the last prerelease build.
If the issue still exist please send us a sample report with test data which reproduces the issue for analysis.

Thank you.
mmmmmm
Posts: 27
Joined: Mon Oct 24, 2011 5:51 am

Re: Totals - ignore NULL values

Post by mmmmmm »

Thank you for your quick answer.
The problem happens in the latest release also.

The exact scenario is the following: a column of positive values having the first element (at row[0]) NULL. The element on the first row is NULL.
With all the other values being greater than 0, the Min is always zero.

Value
------
NULL
12
134
11

If I put a value (non null value) on the first row, then the Min is computed correctly.

Note: I am adding the formula in code behind as below:

Code: Select all

report.RegData(tblDR.TableName, tblDR);                            
report.Dictionary.Synchronize();
report.CalculationMode = StiCalculationMode.Compilation;

StiTable table = new StiTable();
StiTableCell minCell = table.Components[nMinCellIdx] as StiTableCell;

string sMinExpresion = String.Format("{{ Totals.Min({0},{0}.{1}) }}", tblDR.TableName, Stimulsoft.Report.CodeDom.StiCodeDomSerializator.ReplaceSymbols(column.ColumnName));                    

minCell.Text.Value = sMinExpresion;                        
mmmmmm
Posts: 27
Joined: Mon Oct 24, 2011 5:51 am

Re: Totals - ignore NULL values

Post by mmmmmm »

Can anyone suggest a work around for this please?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Totals - ignore NULL values

Post by Alex K. »

Hello,

Please try to set the ConvertNulls property for the report to false.

Thank you.
mmmmmm
Posts: 27
Joined: Mon Oct 24, 2011 5:51 am

Re: Totals - ignore NULL values

Post by mmmmmm »

Hi,

I've tried ConvertNulls = false, but no help. The issue still remains.

Thank you
mmmmmm
Posts: 27
Joined: Mon Oct 24, 2011 5:51 am

Re: Totals - ignore NULL values

Post by mmmmmm »

Looking inside with reflector:

It looks like the Stimulsoft.Report.Dictionary.StiMinDecimalFunctionService.Init() either never gets called or it gets called but never gets to initialize the minimum for the first time due to not meeting the conditions:

Code: Select all

public override void Init()
{
    if (!base.RunningTotal || base.IsFirstInit)
    {
        this.minimum = 79228162514264337593543950335M;
    }
}
Please note that I am adding all data sources and table to page dynamically from code behind.

What do you think?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Totals - ignore NULL values

Post by Alex K. »

Hello,

Please send us a sample report with test data which reproduces the issue for analysis.

Thank you.
Post Reply