简体   繁体   English

SSRS:当多值参数= Select ALL时,删除脚本中的过滤器

[英]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. 我想做的是,如果参数为= Select All,我将把该参数删除到我的SQL脚本中。 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. 您可以将自己的ALL值添加到参数中。 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")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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