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

时间:2016-02-02 14:44:24

标签: sql sql-server reporting-services ssrs-2012

我有一个包含多个多值参数的报告。我想要做的是如果参数是=全选我将删除该参数到我的SQL脚本。 例如,我有一个产品组和产品名称参数,如果用户选择我的脚本将会是的所有产品组,我想要的是:

SELECT * FROM TABLE WHERE PRODUCT_NAME IN (@ProductName)

如果用户没有选择所有产品组,我的脚本将如下:

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

我想知道如何在多值参数=选择全部时检测到。我认为如果我只删除脚本上的过滤器,它将真正有助于工具的加载时间。

3 个答案:

答案 0 :(得分:0)

据我所知,你无法检测到什么时候"全选"已被用户检查。

要在用户选择多值参数中的所有选项时完全删除过滤器,您必须在存储过程中使用逻辑来检查是否所有选项都在参数中传递给它,如果是,不要在主查询中使用该参数。

答案 1 :(得分:0)

您可以将自己的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) 值添加到参数中。在数据集查询中,检查用户是否已选择“全部”'如果是这样的话,请不要使用参数。

这样的事情:

<beans:beans xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:security="http://www.springframework.org/schema/security"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.springframework.org/schema/security
        http://www.springframework.org/schema/security/spring-security-3.1.xsd">

    <!-- ===== SECURITY CONFIGURATION ===== -->

    <!-- All requests matching pattern below will bypass the security filter chain completely -->
    <security:http pattern="/image/**" security="none"/>
    <!--   security:http pattern="/login.jsp*" security="none" / -->

    <!-- Defines who can access each URL. -->
    <!-- 
    Spring Security 3.0 introduced the ability to use Spring EL expressions as an authorization mechanism in addition to the simple use 
    of configuration attributes and access-decision voters which have seen before. Expression-based access control is built on the same 
    architecture but allows complicated boolean logic to be encapsulated in a single expression.
    http://static.springsource.org/spring-security/site/docs/3.0.x/reference/el-access.html
    -->
    <security:http auto-config="true" use-expressions="true">
         <!-- URL restrictions (order is important!) Most specific matches should be at top -->

         <!-- Don't set any role restrictions on login.jsp.  Any requests for the login page should be available for anonymous users -->    
         <security:intercept-url pattern="/login.jsp*" access="isAuthenticated()" /> 

它没有经过测试但应该有效

答案 2 :(得分:0)

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

=IIF(Parameters!AREA.Count = CountRows("Areas"), "ALL", "Some")
相关问题