SSRS Multi Value Parameter. Check whether “Select

2019-02-11 22:14发布

I have a multi value parameter in my SSRS Report. I want to find out whether (Select All) is checked in that parameter.

In other words, whether all the values in the parameter are checked or only some values are checked.

Is it possible?

I am able to find out number of selected values through Parameters!Parameter.Count. Is there a way to find out total of items in that parameter?

7条回答
The star\"
2楼-- · 2019-02-11 22:26

The easy way will be to count the number of the selected parameters and compare them to the dataset

=IIF(Parameters!company_number.Count = CountRows("Dataset1"), True, False)
查看更多
We Are One
3楼-- · 2019-02-11 22:32

In case anyone is still having issues doing this, I just coded this easy fix.

=IIF(COUNTROWS("dataset").Equals(Parameters!parameter.Count),"it is equal","this is not equal")
查看更多
倾城 Initia
4楼-- · 2019-02-11 22:38

For the specific use-case of showing the selected filter on your report in a textbox, here's the expression that will show "All" if "(Select All)" is selected, otherwise it will show all the selected values as a comma-separated list:

=IIF(
     Parameters!YourMultivalueParam.Count = countrows("YourDataset"),
     "All",
     Join(Parameters!YourMultivalueParam.Label,", ")
 )

(split onto multiple lines for readability)

countrows reference: https://technet.microsoft.com/en-us/library/dd255215.aspx


Credit to other answers, just want to extend them for this common scenario.

查看更多
时光不老,我们不散
5楼-- · 2019-02-11 22:38

The problem is if you're trying to pull something for another data set then cross referencing the row count in another dataset won't work. You will have to go with what the previous post states. Create an internal parameter of the exact type and assign the default value to the entire dataset. That way you have the max count of the rows since the hidden parameter.count = rowscount. That way you can use it within another dataset also provided that dataset is AFTER the first one is populated.

查看更多
在下西门庆
6楼-- · 2019-02-11 22:46

According to microsoft's ssrs help search:

=Parameters! .Count Returns the integer value 1. For a single-value parameter, the count is always 1.

I verified this does indeed work, check the integer returned for the built-in parameter count field.

Allow multiple values on a parameter selection. Checking the value of the above field will let you know how many values the user actually chose.

In my situation, I allow multiple values on company number. This gives users the ability to choose one company to report on or several at once. Per client request, if they choose more than one, display data horizontally. If only one company is chosen in the parameter list, show the data vertically and hide the other tablix.

So my visibility show or hide expression looks like this in the one tablix:

=IIF(Parameters!company_number.Count > 1, True, False)

and like this in the other:

=IIF(Parameters!company_number.Count = 1,True,False)

Happy coding! Robyn

查看更多
淡お忘
7楼-- · 2019-02-11 22:49

Your approach sounds good: I would make the options for the parameter come from a dataset.

Then you can use =COUNTROWS("DataSetName") to return the total number of options for your parameter and compare this with Parameters!Parameter.Count as you suggest.

查看更多
登录 后发表回答