2014-01-20 25 views
0

在多值参数的情况下,我们通常使用连接功能将选定值显示在文本框中。但是如果我想要只显示非选定参数?IE如果存在在参数的下拉列表中有10个值,我选择了前5个参数,只想显示剩余的5个参数,而不是前5个。我该怎么办?在SSRS中显示未选中的参数

回答

1

我创建了一个多值参数的名称帕拉姆它有它的标签和值设置像这样:

Label Value 
====== ===== 
Label1  1 
Label2  2 
Label3  3 
Label4  4 
Label5  5 

然后我在报告属性创建了下面的代码 - >代码菜单:

'Global array objects to hold the total and selected values 
Private Dim parameterList() AS string 
Private Dim selectedParameters() AS string 


    'populates the list of all parameters using split and returns the input string 
Public Function SetParameterList(nextParameter as String) AS String 

    parameterList = Split(nextParameter ,",") 

    Return nextParameter 

End Function 


    'populates the list of selected parameters using split and returns the input string 
Public Function SetSelectedParameters(delimitedParameters as String) AS String 

    selectedParameters = Split(delimitedParameters,",") 

    Return delimitedParameters 

End Function 


    'Returns the not selected parameters 
Public Function GetNotSelectedParameters() AS String 

    Dim notSelected As String 
    Dim i as Integer 
    Dim x as Integer 

      'Loop through each value in the all parameters array... 
    For i = 0 to parameterList.GetUpperBound(0) 

        '...for each one of those values check it against the selected parameters 
     For x = 0 to selectedParameters.GetUpperBound(0) 

          'Where there is a match, set the all parameters value to a string unlikely to be a genuine parameter value 
      IF parameterList(i) = selectedParameters(x) Then 

       parameterList(i) = "!*!" 

      End IF 
     Next 

    Next 

      'Join the all parameters array back into a string 
    notSelected = Join(parameterList, ", ") 


      'Remove the !*! values added earlier from the middle and the end of the string 
    notSelected = Replace(notSelected, "!*!, ", "") 
    notSelected = Replace(notSelected, ", !*!", "") 


    Return notSelected 

End Function 

若要使用此代码,我创建文本框3用下面的表达式:

=Code.SetParameterList(Join(LookUpSet(1,1,Fields!ParamLabel.Value,"DataSet1"),",")) 

=Code.SetSelectedParameters(Join(Parameters!Param.Label, ",")) 

=Code.GetNotSelectedParameters() 

注意:要隐藏任何这些文本框的输出,您可以将函数返回值设置为“”。

我想我的代码可以在很大程度上得到改善,但是这样做可以完成工作,并且至少应该让您指向正确的方向。

1

首先创建一个多值参数(“参数1”),其中可用的值的范围从1到10

然后创建一个查询(QUERY1),它返回的参数从1至10滤除 选择的值从“param1” - > where query1.col NOT IN(@ param1)

然后创建另一个多值参数(“param2”),将默认值(从查询中获取值)指向“query1”以填充未选中的值

使用具有以下代码的文本框“= Join(参数!参数1.值”,“”)“

要使查询1可以使用联合。

您将找回未选中的值,