Oct 072013
 

I’ve seen this issue a lot lately.  There is a need to feed a comma delimited string of values into a multi-value parameter in an SSRS report.  There is a simple way to do this.

SET UP YOUR MAIN REPORT QUERY

Your main report query should be set up to expect a string of values in the parameter. For example:

SELECT Product_ID
      ,Item_No
      ,Item_Description
  FROM DIM_Product
  WHERE Item_No IN (@ITEM)
SET UP THE PARAMETER

The parameter should be set up as text, but NOT allow multiple values.

image

You can set this up as you wish to meet your purpose, but for demonstration I will set up two groups of comma delimited strings as available values.

image

I have set up a second data set to feed these default values to the parameter.

SELECT '11000B,2200,17000' AS ITEMNMBR
SET UP THE PARAMETER ON THE MAIN REPORT DATASET

Now comes the magic.  On the Dataset Properties for your main report dataset, on the Parameters tab, edit the expression for the Parameter Value.

image

Write this in the parameter expression:  =split(Parameters!Item.Value,",")

image

This will take the comma delimited string as input, split it into individual values and it will get used in the IN clause of the main query that we set up at the beginning of this post.

WHERE Item_No IN (@ITEM)

Viola, the report filters on a string of values.

image

  16 Responses to “How to use a Delimited String in a Multi-valued Parameter”

  1. Thanks Data Queen 🙂 Your site is the first that explained this well without using crazy functions or SQL. There is a Stack Overflow question here http://stackoverflow.com/questions/17244656/using-ssrs-report-to-pass-in-a-param-value-the-is-a-csv-list-to-sql-dataset that’s pretty helpful too.

  2. Thanks DataQueen just got what was needed simple to implement without using any functions and store procedure

  3. Thanks! Simply solution of my problem!

  4. Problem is…you don’t have a Select All option. How to have a Select All option when using multiple values? With a dropdown list where the user can only select a single value, we can handle the Select All by passing null and checking in the Where clause for a value OR @parameter Is Null

  5. Will this work if the datasets are stored procedures?

  6. removing the multi-value option from the report parameter makes it harder for a user who may want to run an adhoc report. Do you have any suggestions other than requiring a user manually enter their parameters.

  7. Thank you very much for this post. Saved me a lot of time.

  8. Thanks a lot to Author. Your solution was really helpful for me.

  9. Thank you for your sol’n. I am having issues however, getting the ‘Select All’ setup. I followed the link that you provided but I am not following. http://dataqueen.unlimitedviz.com/2011/06/how-to-default-to-all-in-an-ssrs-multi-select-parameter/

    I have followed this sol’n to a ‘T’ but I am getting hung up on how to default (in your scenario) both GroupA and GroupB to be selected when the report is initially executed.

    Any help is greatly appreciated.

    • So what I have done so far is created another label called All with all of the values. May not be the right way to go but it does the trick.

      ie.

      Label Values
      Group A 11000B,2200,17000
      Group B 2000B,2600B
      All 11000B,2200,17000,2000B,2600B

  10. I’m looking for a way to “Explode” a group of values separated by a semicolon and use the values individually in my report. Any suggestions on how to do that.

  11. AWESOME – I have looked everywhere for this answer and you made it so simple. Thank you.

 Leave a Reply

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=""> <s> <strike> <strong>

(required)

(required)

Wordpress SEO Plugin by SEOPressor