SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Hide rows based on parameters fed by a different dataset


Hide rows based on parameters fed by a different dataset

Author
Message
asheppardwork
asheppardwork
SSC Journeyman
SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)

Group: General Forum Members
Points: 75 Visits: 164
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.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search