Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Help with formula for if startswith then Post Reply Post New Topic
Author Message
blazeme182
Groupie
Groupie
Avatar

Joined: 15 Dec 2009
Online Status: Offline
Posts: 44
Quote blazeme182 Replybullet Topic: Help with formula for if startswith then
    Posted: 22 Jul 2011 at 5:39am
I am having some difficulty programming one of my reports.
 
my current formula looks like this:
 
if {Properties.postal_code} startswith 'h4p' then 'West Island'
 
I need to have multiple starting codes what I have tried to do is this:
 
 if {Properties.postal_code} startswith 'h4p' or 'h4m' then 'West Island'
 
But but it keeps telling me that a boolean is required here (shown in Red above).
 
Does anyone have an idea of how to get this done.
 
I basicly need to enter many startsWith values
 


Edited by blazeme182 - 22 Jul 2011 at 5:57am
IP IP Logged
comatt1
Senior Member
Senior Member
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 337
Quote comatt1 Replybullet Posted: 22 Jul 2011 at 6:51am
if {Properties.postal_code} like 'h4p%' then 'West Island'
if {Properties.postal_code} in ['h4p%','h4m%'] then 'West Island'

think startswith is only for selection criteria, not boolean expressions with IF.

Edited by comatt1 - 22 Jul 2011 at 7:36am
IP IP Logged
blazeme182
Groupie
Groupie
Avatar

Joined: 15 Dec 2009
Online Status: Offline
Posts: 44
Quote blazeme182 Replybullet Posted: 24 Jul 2011 at 3:13pm
IP IP Logged
blazeme182
Groupie
Groupie
Avatar

Joined: 15 Dec 2009
Online Status: Offline
Posts: 44
Quote blazeme182 Replybullet Posted: 24 Jul 2011 at 3:19pm
Those did not work. I was able to get it to work the long way. what i did is
 
if {Properties.postal_code} startsWith 'h4p' then 'West Island' + if {Properties.postal_code} startsWith 'h4m' then 'West Island' + if {Properties.postal_code} startsWith 'h4v' then 'West Island'...
 
It would be great if there was a way to do this without so much repetition. I don't know if anyone has better ideas.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 25 Jul 2011 at 4:24am
if it was for one character replacement
if {Properties.postal_code} like ['h4p?','h4m?'] then 'West Island'
if it was for multiple character replacement
if {Properties.postal_code} like ['h4p*','h4m*'] then 'West Island'
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.016 seconds.