Multi-value parameter in SSRS shows blank

  • Hi,

    I am trying to run a report based on a stored procedure. The report uses 3 parameters and one of them (@comp_name) has a multi-select option for the users.

    When I run the report for one value, the report shows the corresonding data, however, when multiple values are selected, then it draws a blank.

    I have used a split function to sort out this issue but this doesnt work.

    Could someone please tell what needs to be changed in the stored procedure / ssrs report ?

    Please find the stored procedure attached. Also, below are the sample values in the parameter:

    "V" trade (germany) a/s

    "V" trade (espana) ltd.

    "V" trade (italia) srl

    "V" trade (belgium) N.V.

    Thanks.

  • Looking at the SP it looks like you were on the right track to fixing the issue with the dbo.Split() function. When passing multi-value parameters to an SP you have to split them in order for the query to return the results you want, particularly when they parameter is passing string values. In your case the value in @comp_name is something like:

    'trade (germany) a/s, trade (espana) ltd.'

    So SQL Server is treating that a single string value so the where clause SQL is evaluating is:

    r1.comp_name IN ('trade (germany) a/s, trade (espana) ltd.' )

    And what you want is:

    r1.comp_name IN ('trade (germany) a/s', 'trade (espana) ltd.' )

  • Jack Corbett (7/3/2014)


    Looking at the SP it looks like you were on the right track to fixing the issue with the dbo.Split() function. When passing multi-value parameters to an SP you have to split them in order for the query to return the results you want, particularly when they parameter is passing string values. In your case the value in @comp_name is something like:

    'trade (germany) a/s, trade (espana) ltd.'

    So SQL Server is treating that a single string value so the where clause SQL is evaluating is:

    r1.comp_name IN ('trade (germany) a/s, trade (espana) ltd.' )

    And what you want is:

    r1.comp_name IN ('trade (germany) a/s', 'trade (espana) ltd.' )

    Thanks,

    As I mentioned, I tried using the split function to resolve it but still getting the same result. The report shows no data. I don't know what other option I have.

  • Can you share the Split code?

    Have you verified that the split function is returning what you expect?

    When you pass in a single value using the Split function do you get results returned?

    What is the datatype of the Item returned by the Split function? Does it match the column datatype?

    I've done exactly what you are doing with the Split function when working with multi-value parameters without issue, so I have to think there is something odd goign on with the split function.

  • Jack Corbett (7/3/2014)


    Can you share the Split code?

    Have you verified that the split function is returning what you expect?

    When you pass in a single value using the Split function do you get results returned?

    What is the datatype of the Item returned by the Split function? Does it match the column datatype?

    I've done exactly what you are doing with the Split function when working with multi-value parameters without issue, so I have to think there is something odd goign on with the split function.

    Thanks again.

    Please find the split code attached.

    I noticed that even if I select a single value, the data still doesnt get displayed on the report.

    The datatype of the item is nvarchar(4000) and datatype of the comp_name column is nvarchar(255).

  • Hi,

    I need a code for a split function that can also handle double quotes in values along with the usual commas. Could anyone please help in this regard ?

    I need this function for a multi-select report parameter which has the following sample values:

    "V" trade (germany) a/s

    "V" trade (espana) ltd.

    "V" trade (italia) srl

    "V" trade (belgium) N.V.

    Thanks.

  • Any help would be appreciated...

  • We have a function that we use to split out the parameters from Reporting Services. I am not sure how it would handle the quotes. You would have to test that.

  • pwalter83 (7/4/2014)


    Hi,

    I need a code for a split function that can also handle double quotes in values along with the usual commas. Could anyone please help in this regard ?

    I need this function for a multi-select report parameter which has the following sample values:

    "V" trade (germany) a/s

    "V" trade (espana) ltd.

    "V" trade (italia) srl

    "V" trade (belgium) N.V.

    Thanks.

    What do you mean by "handle" double-quotes?

    When I use your split function is looks like the issue is that spaces are being removed and have nothing to do with the double-quotes.

    I recommend using Jeff Moden's split functions as found in his article here on SSC, http://www.sqlservercentral.com/articles/Tally+Table/72993/. I have tested this function against your data and it splits it correctly.

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply