Print Page | Close Window

Multiple conditions for if statement

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=21392
Printed Date: 05 May 2024 at 12:41am


Topic: Multiple conditions for if statement
Posted By: bremen
Subject: Multiple conditions for if statement
Date 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



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


Posted By: bremen
Date Posted: 23 Mar 2015 at 7:04am
Thank you very much.  



Print Page | Close Window