Print Page | Close Window

Help with formula for if startswith then

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2022
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=13842
Printed Date: 19 Apr 2025 at 1:00pm


Topic: Help with formula for if startswith then
Posted By: blazeme182
Subject: Help with formula for if startswith then
Date 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
 



Replies:
Posted By: comatt1
Date 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.


Posted By: blazeme182
Date Posted: 24 Jul 2011 at 3:13pm


Posted By: blazeme182
Date 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.


Posted By: DBlank
Date 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'



Print Page | Close Window