我正在尝试使用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")
单击"类别"文本框时发生错误
没有子类别参数传递
为什么?或者我应该改变自己的想法?