Author |
Message |
gitanjali1027
Newbie
Joined: 01 Apr 2010
Online Status: Offline
Posts: 25
|
Topic: Specifying String Length Posted: 15 Apr 2010 at 9:29am |
I am trying to get the first 25 characters of a string field i have in my report.
I have tried the following:
{DataTable1.Name} = Left({DataTable1.Name},26)
however i find that instead of showing 26 characters, it is truncating the list of things that is populating my report...so that only 26 items show on my report. It's kind of an odd problem
Does anybody else have any ideas on how to specify a string length?
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|
Posted: 15 Apr 2010 at 9:31am |
Soundls like you are putting this in the Select Expert.
The select Expert is only used to limit data returned.
Just add a new formula field (in the field explorer) as:
Left({DataTable1.Name},25)
place the formula field on your report canvas to display your desired result
Edited by DBlank - 15 Apr 2010 at 9:32am
|
IP Logged |
|
gitanjali1027
Newbie
Joined: 01 Apr 2010
Online Status: Offline
Posts: 25
|
Posted: 15 Apr 2010 at 9:38am |
Ah yes, i was in fact using the Select Expert. This worked so well, THANK YOU!
|
IP Logged |
|
gitanjali1027
Newbie
Joined: 01 Apr 2010
Online Status: Offline
Posts: 25
|
Posted: 15 Apr 2010 at 9:51am |
one thing though--it seems to love to truncate a word in the middle of a letter. any way to avoid that?
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|
Posted: 15 Apr 2010 at 10:14am |
What do you want your logic to be to handle it?
Truncate at the first " " after 25 characters?
|
IP Logged |
|
gitanjali1027
Newbie
Joined: 01 Apr 2010
Online Status: Offline
Posts: 25
|
Posted: 15 Apr 2010 at 10:30am |
Basically i want to to be that the max length is 25 chars. Meaning any chars above 25 do not show up (rather than truncate in the middle of the letter).
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|
Posted: 15 Apr 2010 at 10:47am |
try this:
left({DataTable1.Name},instrrev(left({DataTable1.Name},25),' ')-1)
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|
Posted: 15 Apr 2010 at 10:50am |
Actually that will error if the string is less than 25 and ther is no " " in it so try:
if length({DataTable1.Name})<25 then {DataTable1.Name} else if lengthleft({DataTable1.Name},instrrev(left({DataTable1.Name},25),' ')-1)
|
IP Logged |
|
gitanjali1027
Newbie
Joined: 01 Apr 2010
Online Status: Offline
Posts: 25
|
Posted: 16 Apr 2010 at 2:46am |
I tried the last formula you posted, however I keep getting errors when I tried to put it in the formula. It kept saying 'A number, currency amount, boolean, date, time, date-time, or string is expected here' and it highlights the lengthleft portion.
|
IP Logged |
|
kevlray
Admin Group
Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
|
Posted: 16 Apr 2010 at 4:33am |
I see a left parathesis missing between length and left in the second if. Also you have a second if and no then. And you have a left, but no value for that left.
Edited by kevlray - 16 Apr 2010 at 4:40am
|
IP Logged |
|
|