Occasionally I use this blog to post bits of code that I might, one day, need again and justify it by telling myself that someone else, somewhere, might need one day need the same as well. This is one such blog post.
The following code converts a multivalue parameter in SQL Server Reporting Services into a comma delimited list:
Public Function ConvertMultivalueParameterToCommaDelimitedList(ByVal Parameter as Parameter) as String
Dim s as String
If parameter.IsMultiValue then
s = ""
For i as integer = 0 to parameter.Count-1
s = s + CStr(parameter.Value(i))
If i <> parameter.Count-1 Then s = s + ","
s = "Single value: " + CStr(parameter.Value)
Thank you to Ostrosoft for their VB code-to-HTML converter.
That is all!!
UPDATE: Turns out that there is a function in SSRS’s expression language that does this for you. Its called Join and you can read more about it on Luke Hayler’s blog post The JOIN() Function in SSRS. Thanks to KD and Dave in the comments!