The JOIN() Function in SSRS

BOL’s description of the JOIN() Function: “Returns a string created by joining a number of substrings contained in an array.”. The syntax of the function is as follows:

=JOIN(List [,delimiter])

List – Required. One-dimensional array containing substrings to be joined

Delimiter – Optional. String character used to separate substrings. If omitted, a space “ “ will be used.

So, the JOIN() Function concatenates an array’s values, using either a default space or the specified separator (for example, “, “) to separate the values.

What are the practical uses of this function as it relates to Reporting Services?

A common use of the function in Reporting Services is to display the values being used in a Multi-valued Parameter. You may for example have a report that has a parameter that filters Sales Regions. A requirement of the report is to display, in the header, the Sales Regions that the report is for. In the header of the report you would include the following expression:

=”Monthly Sales Report, for Regions:  ” & JOIN(Parameters!SalesRegion.Value, “, “)

Previewing this in the report with the following regions selected from the SalesRegion Multi-Value Parameter:

  • North America
  • South America
  • Southern Africa

Will result in the following Header string:

Monthly Sales Report, for Regions:   North America, South America, Southern Africa

I have mentioned this function here as I find it very useful and have used it on many occasions. The above use is only one of many, but for me, is the most common.

Share and Enjoy:
  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks

14 thoughts on “The JOIN() Function in SSRS

  1. Pingback: SSIS Junkie : SSRS Helper Code : Convert a multivalue parameter to a comma delimited string

  2. Luke,

    Thanks again for the write up. Got any ideas on how i could add a switch statement into something like this? Got a list comming back but want to change the display value.

    Thanks,
    Justin

  3. Can “JOIN” be used to concatenate multiple field values (in the example, parameter values are used) as well. Please give a work around for this case.

    • Hi Aditya,

      The JOIN() function will concatenate an array of values (hence the use of a multi-valued parameter). As Field values are single items you will not be able to use the JOIN() function. i.e.

      =JOIN(Fields!MyField.Value, “,”) will not work.

      I would suggest you either perform the concatenation of your fields in your SQL query, or use an expression in your report – something to the effect of:

      =Fields!MyField.Value + “, ” + Fields!MyOtherField.Value

      Personally, I would perform the concatenation in the Query/View/Stored Procedure.

      Might I ask what you are trying to achieve?

  4. No errors but if size was over 8000 then nothing was being pasted to the database. What we did was to use the max option (nvarchar(max)) and set the field size to max also and that solved it.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.