How to hide parameter based on another parameter value in SSRS

偶尔善良 提交于 2020-01-02 11:07:26

问题


Hi I have 2 parameters param1 and param2. param1 has values true and false.my requirement is if i select true in param1 then param2 should be hidden and if i select false in param1 then param2 should be visible. can this be achieved in SSRS?


回答1:


As per Nathan's comment i am adding Amar's comment here as answer/partial answer

Unfortunately, you cannot change a parameter's visibility during run time. Alternatively, you can control the second parameter's values based on the selected value of the first parameter.

Check this post - Hide parameter (dropdown control from the toolbar) in SSRS based on another Parameter




回答2:


As Amar pointed out you cannot hide parameters dynamicly, but what you can do is grey them out for single-value parameters, described here. For multi-value parameters that won't work, because multi-value parameters are not allowed to be null.

But instead you can modify your DataSet and the default value for the parameter. To limit the user's choice list. Let me give you an example:

Let's say you have 2 parameters that are cascaded. So you want to choose something from the first parameter and depending on what you choose in the first parameter you get a different result in second parameter. (Microsoft has a documentation about this)

Now we can use this cascading to set the values in the second parameter. So for instance if we choose the value 1 in the first parameter we want the second parameter act normal and show its data to choose from, but in any other case we want the second parameter to have limited data to choose from. And this what I'am going to show. You got a second parameter that looks like this:

In the Available Values we choose the DataSet with its values and labels for the sceond parameter. Which could look like this:

Now in the DataSet for the second parameter, here DataSet1, we need to specify when to show the limited data and when not:

So what we do is set one label All with the value -1 when the value of the first parameter is not 1 else the DataSet returns all the data from the table/function/stored procedure/ etc.

Lastly the second parameter shall have the default value -1 with the label All choosen when the first parameter is not 1. So back to the second parameter properties. For Default Values the value -1 needs to be specified:

So now the user only gets the preselected All in the list to choose from when the first parameter is not 1. Otherwise the full list will be provided. All that has to be done now is to declare what is done when the value of the second parameter is -1.

I hope that helps someone else. Let me know in the comments.



来源:https://stackoverflow.com/questions/26246168/how-to-hide-parameter-based-on-another-parameter-value-in-ssrs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!