SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Need HELP on SSRS SPLIT function


Need HELP on SSRS SPLIT function

Author
Message
tinnusqlserver
tinnusqlserver
SSC-Enthusiastic
SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)

Group: General Forum Members
Points: 185 Visits: 230
Hi All I need your advice,

1) I have a dynamic string which changes each time.

for example today the string will be "ItemA,ItemB,ItemC" and tomorrow it will be "itemA,ItemB" only.

2) I have an SSRS report which has 3 columns

3) I want to split this string "ItemA,ItemB,ItemC" and want to show splitted substrings in these 3 columns of ssrs table. the Delimiter is "," (comma)

4) I had used

=Split("ItemA,ItemB,ItemC",",").GetValue(0) in the first column of the report

=Split("ItemA,ItemB,ItemC",",").GetValue(1) in the second column of the report

=Split("ItemA,ItemB,ItemC",",").GetValue(2) in the third column of the report

5) everything works fine until my string is "ItemA,ItemB,ItemC" ,


BUT WHEN MY STRING CHANGES TO "ItemA,ItemB", then I am seeing "#Error" in the third column.

I understood the error, for

=Split("ItemA,ItemB,ItemC",",").GetValue(2) we dont have any value because the string now has only 2 values after applying split function



Is there any way i can avoid #Error in the third column.

NOTE: I have to compulsorily use 3 columns in the ssrs report.

I had tried using =Replace(Split("ItemA,ItemB",",").GetValue(2),"#Error","NULL") in the third column but that also wont worked.



Appreciate Your Help,

Raj Vardhan
Daniel Forrester 123
Daniel Forrester 123
Mr or Mrs. 500
Mr or Mrs. 500 (592 reputation)Mr or Mrs. 500 (592 reputation)Mr or Mrs. 500 (592 reputation)Mr or Mrs. 500 (592 reputation)Mr or Mrs. 500 (592 reputation)Mr or Mrs. 500 (592 reputation)Mr or Mrs. 500 (592 reputation)Mr or Mrs. 500 (592 reputation)

Group: General Forum Members
Points: 592 Visits: 195
Hi,

You could write a function using the embedded code option in SSRS. This would enable you to use better string manipulation functions and error handling in VB.

Regards
Daniel
Steven.Howes
Steven.Howes
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1626 Visits: 2354
What if you cheated and appended a few extra commas to your string so that it looked like:

"ItemA,ItemB,,,", or "ItemA,,,"

That way your split function would return a blank string.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search