Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Multiple conditions for if statement Post Reply Post New Topic
Author Message
bremen
Groupie
Groupie
Avatar

Joined: 28 May 2013
Online Status: Offline
Posts: 93
Quote bremen Replybullet Topic: Multiple conditions for if statement
    Posted: 23 Mar 2015 at 3:31am
I have to write a formula with several "if then else" statements.  Each of the statements has multiple conditions. 

for example

if

 {Table1.Field1} > X, but < X  
and
{Table2.Field2 }= X
then
"Text String Here"
else
...

Help Please
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 23 Mar 2015 at 4:34am
you have to be more specific to get specific assistance
your example is unclear with the 'but' condition.
 
In general consider
1. if there are NULLs invloved. This will impact the process greatly. a formula will stop evaluating when it hits a NULL unless you explicitly state how to handle it. This can either be in the formula or in the formula editor "NULL options' pick list.
2. Consider a hierarchy of condition sets. Once a condition set is met the formula stops evaluating. If you have multiple 'if-then' statements your second 'if-then' only runs against the rows that did not meet the first 'if-then'
3. How and where you use parenthesis in each condition set
4. consider using "NOT()" in conditions
 
for example

if {Table1.Field1} > X OR  ({Table1.Field1} < X and {Table2.Field2 }= X)
then "Text String Here" else
if condition set 2 here...
 


Edited by DBlank - 23 Mar 2015 at 7:33am
IP IP Logged
bremen
Groupie
Groupie
Avatar

Joined: 28 May 2013
Online Status: Offline
Posts: 93
Quote bremen Replybullet Posted: 23 Mar 2015 at 7:04am
Thank you very much.  
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.