question

sanjeev.matte avatar image
sanjeev.matte asked

Concatenate multiple values into single string.

Hello Everyone, I have a parameter @Month in a report which was created in SSRS and it is having an option of selecting multiple values.I am using this parameter in Split function, So it passes as Split('Jan','Feb','March',',') which gives an error "Too many arguments for split function". Can someone please give solution to get concatenate these three values as a single string.
parametersconcatenation
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

KenJ avatar image
KenJ answered
If it is passing in the single quotes between the items, try changing the delimiter you're splitting on to account for the extra single quotes: `Split(@Month, ''',''')`
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hi Ken, Thanks for your reply.But this is not working because, The parameter is replaced as Split('Jan','Feb','March',',') Which could give the error. And i don't think there is a problem with ','.
0 Likes 0 ·
you can get rid of all the single quotes: `Split(replace(@month, '''', ''), ',')` or you can double them up: `Split(replace(@month, '''', ''''''),',')` which will leave single quotes around the month names after they are split. either way, you may need to enclose the entire thing in quotes before splitting it: `set @month = ''' + @month + ''''`
0 Likes 0 ·
ThomasRushton avatar image
ThomasRushton answered
Try this: split('''jan'',''feb'',''march''', ',') The problem is that your string is built up with 's, and that's also the string delimiter. So you need to escape (by doubling) those quotes within the string itself.
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hi Thomas, Thanks for reply, As i am using parameter to pass these values can you please update the parameter instead of the values.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.