当前位置:  开发笔记 > 编程语言 > 正文

使用级联参数在SSRS中实现切片器

如何解决《使用级联参数在SSRS中实现切片器》经验,为你挑选了0个好方法。

我正在尝试使用AdventureWorks2012(http://msftdbprodsamples.codeplex.com/downloads/get/165399)在SSRS中使用级联参数实现切片器.有三个数据集:一个(SalesbyCategory)用于报告,另一个用于参数.

这是查询:SalesbyCategory:

SELECT        PC.Name AS Category, PSC.Name AS Subcategory, P.Name AS Product
FROM            Production.Product AS P INNER JOIN
                         Production.ProductSubcategory AS PSC ON P.ProductSubcategoryID = PSC.ProductSubcategoryID INNER JOIN
                         Production.ProductCategory AS PC ON PC.ProductCategoryID = PSC.ProductCategoryID
WHERE        (PC.Name IN (@Category)) AND (PSC.Name IN (@Subcategory)) 

CategoryValues:

SELECT DISTINCT Name AS Category
FROM            Production.ProductCategory

SubcategoryValues:

SELECT DISTINCT PSC.Name AS Subcategory
FROM            Production.ProductSubcategory AS PSC INNER JOIN
                         Production.ProductCategory AS PC ON PC.ProductCategoryID = PSC.ProductCategoryID
WHERE        (PC.Name IN (@Category))

反函数的函数:

Function parameterInverse(ByVal paramsArray As String(), ByVal parameter As String) As String()
    For i As Integer = 0 To paramsArray.Length - 1
        If paramsArray(i).Equals(parameter) Then                    
            paramsArray(i) = paramsArray(paramsArray.Length - 1)
            ReDim Preserve paramsArray(paramsArray.Length - 2)
            Exit For
        ElseIf i = paramsArray.Length - 1 Then                      
            ReDim Preserve paramsArray(paramsArray.Length)
            paramsArray(paramsArray.Length - 1) = parameter
        End If
    Next
    Return paramsArray
End Function

文本框操作:类别

=Code.parameterInverse(Split(Join(Parameters!Category.Value,","),","),Fields!Category.Value)

Subcategory = [@Subcategory]

表达式以显示是否选择了参数:

=iif(Join(Parameters!Subcategory.Value,",").Contains(Fields!Subcategory.Value),"Turquoise","LightGrey")

单击"类别"文本框时发生错误

没有子类别参数传递

在此输入图像描述

为什么?或者我应该改变自己的想法?

推荐阅读
李桂平2402851397
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有