Using conditional aggregate functions in Filter expression

Stimulsoft Reports.NET discussion
Post Reply
dghani
Posts: 3
Joined: Thu Dec 03, 2009 10:41 am

Using conditional aggregate functions in Filter expression

Post by dghani »

I am trying to filter a data band based on the number of items in a child band that meet some criterion, and have tried a filter expression like:

CountIf(DataBand, DataSource.Column, DataSource.Column=="ciriterion") > 0

However, I get a message saying that "CountIf" does not exist. Any suggestions as to whether this is possible to do, and if so, what am I doing wrong?

If it is not possible, how could this sort of filtering be achieved?
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Using conditional aggregate functions in Filter expression

Post by Edward »

Hi

Please change the expression as follows:

Totals.Sum(DataBand1,DataSource.Column=="ciriterion"?1:0)>0

Thank you.
dghani
Posts: 3
Joined: Thu Dec 03, 2009 10:41 am

Using conditional aggregate functions in Filter expression

Post by dghani »

Hi Edward,

Thanks for the quick response. Your suggestion sounds reasonable, and it compiles ok, but still doesn't work as a filter - it appears to return 0 even when items meeting the criterion are present. When I put the same expression (minus the "Totals." and the ">0") in a Text box in the databand I am trying to filter, the correct result is shown.

Is there something very different about the environment in which the expression is evaluated in the filter as opposed to a text component?
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Using conditional aggregate functions in Filter expression

Post by Edward »

Hi

Please try to use the following expression instead:

Totals.Sum(DataSource,DataSource.Column=="ciriterion"?1:0)>0

Thank you.
dghani
Posts: 3
Joined: Thu Dec 03, 2009 10:41 am

Using conditional aggregate functions in Filter expression

Post by dghani »

Hi Edward,

Using the data source instead of the databand in the filter expression gives the total of all records in the data source that meet the criterion regardless of the relation : I need the total of only the records related to each master record in order to filter it.

My real problem is actually more complex - I am trying to filter based on a comparison between the counts using two different criteria, hence I was trying to use CountIf in the sort expression in the master band.

Have you any other suggestions for working around this?

Thanks
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Using conditional aggregate functions in Filter expression

Post by Edward »

Hi

Please send your report and data for it to support[at]stimulsoft.com for analysis.

Thank you.
Post Reply