Search code examples
sqlsql-serverreporting-servicesssrs-2008ssrs-2008-r2

How to use aggregate function to filter a dataset in ssrs 2008


I have a matrix in ssrs2008 like below:

GroupName   Zone    CompletedVolume 
Cancer      1       7
Tunnel      1       10
Surgery     1       64

ComplatedVolume value is coming by a specific expression <<expr>>, which is equal to: [Max(CVolume)]

This matrix is filled by a stored procedure that I am not supposed to change if possible. What I need to do is that not to show the data whose CompletedVolume is <= 50. I tried to go to tablix properties and add a filter like [Max(Q9Volume)] >= 50, but when I try to run the report it says that aggregate functions cannot be used in dataset filters or data region filters. How can I fix this as easy as possible?

Note that adding a where clause in sql query would not solve this issue since there are many other tables use the same SP and they need the data where CompletedVolume <= 50. Any help would be appreciated.

EDIT: I am trying to have the max(Q9Volume) value on SP, but something happening I have never seen before. The query is like:

Select r.* from (select * from results1 union select * from results2) r 
left outer join procedures p on r.pid = p.id

The interesting this is there are some columns I see that does not included by neither results1/results2 nor procedures tables when I run the query. For example, there is no column like Q9Volume in the tables (result1, result2 and procedures), however when I run the query I see the columns on the output! How is that possible?


Solution

  • You can set the Row hidden property to True when [Max(CVolume)] is less or equal than 50.

    Select the row and go to Row Visibility

    enter image description here

    Select Show or Hide based on an expression option and use this expression:

    =IIF(
    Max(Fields!Q9Volume.Value)<=50,
    True,False
    )
    

    It will show something like this:

    enter image description here

    Note maximum value for Cancer and Tunnel are 7 and 10 respectively, so they will be hidden if you apply the above expression.

    Let me know if this helps.