Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Truncating a string but adding specific exceptions Post Reply Post New Topic
Author Message
kpsmithuk
Newbie
Newbie
Avatar

Joined: 03 Feb 2011
Location: United Kingdom
Online Status: Offline
Posts: 15
Quote kpsmithuk Replybullet Topic: Truncating a string but adding specific exceptions
     Posted: 27 Apr 2012 at 12:02am
I have a list of country names from our CRM system but they have a 2 character code in brackets after the name.
 
This means the map function in CR2008 has a fit as nothing matches on the wold map.
 
I took care of this using this formula: To remove the last 4 characters.
 
if len({CountryCode.coun_name})<3 then {CountryCode.coun_name}
 
else
 
left({CountryCode.coun_name},len({CountryCode.coun_name})-4)
 
I need to add in exceptions e.g
 
The country name for the USA is United States (US)
 
This needs to be USA
 
I thought I could simply do
 
(if {CountryCode.coun_name} = "United States" then {CountryCode.coun_name} = "USA (US)"
 
else
 
if exeption 2........)
 
else
 
(if len({CountryCode.coun_name})<3 then {CountryCode.coun_name}
 
else
 
left({CountryCode.coun_name},len({CountryCode.coun_name})-4)
)
 
However this returns and error - any clues????
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 27 Apr 2012 at 2:13am
You are getting an error because the first if then is returning a Boolean.
Do not try to alter your original field but rather return the value you want...
If {CountryCode.coun_name}='united states' then 'USA' else
If ....

Edited by DBlank - 27 Apr 2012 at 3:12am
IP IP Logged
kpsmithuk
Newbie
Newbie
Avatar

Joined: 03 Feb 2011
Location: United Kingdom
Online Status: Offline
Posts: 15
Quote kpsmithuk Replybullet Posted: 27 Apr 2012 at 2:46am
Marvelous - I didn't think about the boolean part
 
Makes sense now.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum