Adding VB Scripts Inside SSRS Reports

Posted By Posted by: EPM Partners on November 12, 2012

Problem: Converting a comma separated string outputted from a multi select parameter into an array of strings to be used in SSRS report expressions.

Solution: You can store custom VB code in an SSRS report and this functionality can be used to include a variety of custom built functions but in this case it will be used to convert a string to an array.

  • In the SSRS report, go to Report > Report Properties > Code > Custom Code
  • Include the following VB script to convert a string to an array into the Custom Code section:

Public shared FUNCTION ConvertStringtoArray(stringToConvert as String) As String()

Dim arrayOfStrings As String() = stringToConvert.Split(“,”)

return arrayOfStrings

End Function

  • In order to call the above function in an SSRS expression, enter =Code.[function name] (e.g.=Code.ConvertStringtoArray(Parameter!ParamToConvert.Value))

Blog Posted In Blog Posted In: Reporting
Blog Posted In 

Leave a Reply

Your email address will not be published. Required fields are marked *