Hide rows based on parameters fed by a different dataset

  • I just learned a new trick and had to share since it took hours to find the answer (even after searching here).

    Using SSRS 2008 R2 on a Windows 8.1 machine.

    I have a report that for several reasons has three datasets, but only one tablix. The Main dataset populates the data for the tablix. The Branches and Salespersons datasets are there to get a list for parameters used to filter the Main dataset. So, the pms SALESPERSON and Branch are accessed via drop downs by the user and allows them to select all or some combination of all (multivalue). When a selection is made, the Main dataset is filtered and thus they can see a segment of the report.

    The problem was that I had a redundant totals row at the bottom. It became unnecessary whenever only one branch or one salesperson was selected. The primary purpose of this report is to report to branches, so more often than not the report will be run with only one branch selected; and due to grouping the branch has a subtotal at the bottom of it no matter what.

    Since the Branches in the main dataset are filtered by the parameter, comparing the count of Branches in the Main dataset to the Parameter always equaled each other; which was not helpful.

    Also, trying to use a cobbled together statement like ="Select Distinct Branch from table where field in (" + Parameters!Branch.Value + ")" was useless since the "+" and "&" are undefined for the pm object.

    Then I thought I could do a count of rows in Branches dataset and then pass that number to the Main dataset; which again proved fruitless as it was out of scope.

    Finally I happened upon a post : http://stackoverflow.com/questions/3704453/ssrs-can-i-know-if-user-selected-all-in-multivalued-param/20846627#20846627 by Jordan Arron (http://stackoverflow.com/users/3742/jordan-arron)

    He suggested that to correct the problem a secondary "hidden" parameter be used to compare to the exposed parameter.

    So, that's what I did. I created a pm identical to the Branches pm only marking it as internal. Then in the Row Visibility >Show or Hide based on expression I used: =IIF(Parameters!Branch.Count = Parameters!Branch_Hidden.Count,False,True) and viola the report hides the row based on if all the branches are selected (which they are by default) or if less than that are selected.

    I could even go further and use >< + - with the count properties if I wanted the total's line to work with 2 or more selections, but not with only 1.

    That's it, if you have a situation like this one; create a "hidden" parameter that defaults to the same choices as the exposed ones and you have a way of hiding rows based on parameters that are fed by datasets not being used in the current tablix.

Viewing 0 posts

You must be logged in to reply to this topic. Login to reply