SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Analysis Server and Reporting Services (2008)
 Need Help on SSRS SPLIT function
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

raj vardhan43
Starting Member

USA
20 Posts

Posted - 10/19/2012 :  18:05:37  Show Profile  Reply with Quote
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




raj

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 10/19/2012 :  23:07:05  Show Profile  Reply with Quote
where does the string of value come from? can this be done from the source?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 10/20/2012 :  09:02:31  Show Profile  Reply with Quote
Add 3 dummy comma's to the end of the first parameter:
=Split("ItemA,ItemB,ItemC"+",,,",",").GetValue(2)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000