Display Parameter(Multi-value) in Report

后端 未结 4 1405
终归单人心
终归单人心 2021-01-31 01:24

Can anyone tell me how to display all the selected value of my multi value parameter in SSRS report. When giving parameter.value option it gives error.

相关标签:
4条回答
  • 2021-01-31 01:34

    Hopefully someone else finds this useful:

    Using the Join is the best way to use a multi-value parameter. But what if you want to have an efficient 'Select All'? If there are 100s+ then the query will be very inefficient.

    To solve this instead of using a SQL Query as is, change it to using an expression (click the Fx button top right) then build your query something like this (speech marks are necessary):

    = "Select * from tProducts Where 1 = 1 " 
    IIF(Parameters!ProductID.Value(0)=-1,Nothing," And ProductID In (" & Join(Parameters!ProductID.Value,"','") & ")")
    

    In your Parameter do the following:

        SELECT -1 As ProductID, 'All' as ProductName Union All
        Select  
        tProducts.ProductID,tProducts.ProductName
        FROM
        tProducts
    

    By building the query as an expression means you can make the SQL Statement more efficient but also handle the difficulty SQL Server has with handling values in an 'In' statement.

    0 讨论(0)
  • 2021-01-31 01:36

    =Join(Parameters!Product.Label, vbcrfl) for new line

    0 讨论(0)
  • 2021-01-31 01:49

    You can use the "Join" function to create a single string out of the array of labels, like this:

    =Join(Parameters!Product.Label, ",")
    
    0 讨论(0)
  • 2021-01-31 01:54

    I didn't know about the join function - Nice! I had written a function that I placed in the code section (report properties->code tab:

    Public Function ShowParmValues(ByVal parm as Parameter) as string
       Dim s as String 
    
          For i as integer = 0 to parm.Count-1
             s &= CStr(parm.value(i)) & IIF( i < parm.Count-1, ", ","")
          Next
      Return s
    End Function  
    
    0 讨论(0)
提交回复
热议问题