Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Need HELP on SSRS SPLIT function Expand / Collapse
Author
Message
Posted Friday, October 19, 2012 4:07 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, September 12, 2013 9:58 AM
Points: 39, 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


Post #1375055
Posted Thursday, November 29, 2012 4:49 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Tuesday, September 3, 2013 3:51 AM
Points: 263, Visits: 177
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
Post #1390426
Posted Friday, November 30, 2012 7:10 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Thursday, August 21, 2014 7:26 AM
Points: 582, Visits: 2,090
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.
Post #1391291
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse