简体   繁体   中英

SSRS: When Multi-value Parameter = Select ALL remove filter in Script

I have a report that has multiple multi-value parameter. What I wanted to do is if the parameter is = Select All I'll remove that parameter to my SQL Script. Example is I have a Product group and Product Name parameter and what I want is if the user selects all the product group my script will be like:

SELECT * FROM TABLE WHERE PRODUCT_NAME IN (@ProductName)

While if the user did not select all Product Group, my script will be like:

SELECT * FROM TABLE WHERE PRODUCT_NAME IN (@ProductName)
AND PRODUCT_GROUP IN (@ProductGroup)

I want to know how Can I detect when multi-value parameter is = Select All. I think it will really help the loading time of the tool if I just remove the filter on my script.

As far as I know, you cannot detect when "Select All" has been checked by the user.

To remove the filter completely when the user selects all the choices in a multi-valued parameter you would have to employ logic in your stored procedure that checks to see if all the choices were passed to it in the parameter, and if so, don't use the parameter at all in the main query.

You can add your own ALL value to the parameter. In the dataset query check if the user have selected 'ALL' if so don't use the parameter.

Something like this:

IF ('ALL' IN @ProductGroup)
BEGIN 
  SELECT * FROM TABLE WHERE PRODUCT_NAME IN (@ProductName)
END
ELSE
  SELECT * FROM TABLE WHERE PRODUCT_NAME IN (@ProductName)
  AND PRODUCT_GROUP IN (@ProductGroup)

It is not tested but should work

如果参数基于数据集,则可以比较参数中所选元素的数量与参数数据集中项目的数量。

=IIF(Parameters!AREA.Count = CountRows("Areas"), "ALL", "Some")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM