Powered By Blogger

Tuesday, March 27, 2012

Displaying Multi Valued Parameters in Reporting Services

Its quite normal to want to display the value of the parameters you have used to run a report within the report body. For one thing, once the report has been printed out, the person reading it can tell how it was run. For single values parameters you can simply create a text box and put the expression

=Parameters!pTeam.Label

to display your single team parameter. But if its a multi-valued parameter you have to work a tiny bit harder. For starters you'll need to add a bit of custom code to your report. You get to this through

Report -> Report properties -> Code

and you then enter this little code unit:


Public Shared Function PrintArray(ByVal Value As Array, ByVal Count as Integer) As String


dim i as Integer
PrintArray = ""
For i = 0 to Count -1
PrintArray = PrintArray & Iif(i>0,", ","") & LTrim(Value(i))
Next


'PrintArray = LTrim(Value)


End Function 

To pick this up and make use of it you just create a text box as before but enter the expression:

=Code.PrintArray(Parameters!pTeam.Label, Parameters!pTeam.Count)

This will print out the values you have entered as comma separated list.


No comments:

Post a Comment

Would love to get feedback on any of my posts.