Print Page | Close Window

AND operator

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=8314
Printed Date: 03 May 2024 at 1:19pm


Topic: AND operator
Posted By: tiffnobody
Subject: AND operator
Date Posted: 12 Nov 2009 at 8:22am
i'm trying to write a formula using the AND operator but the conditions are based on two separate fields that have nothing to do with each other and one condition is a bit more complicated.  here is what i have:
 
Iif ( ({CnAdrPrf.CnAdrPrf_Type} in ["Good - Busines","Good - Foundation","Good - Home","Good - Seasonal","Home"])
and ( {CnBio.CnBio_Deceased}="No"), 1)
 
what i am trying to do is if both conditions are satisfied, i want a 1 assigned to them, and if both conditions are not satisfied, i want a 0 assigned to them.



Replies:
Posted By: JohnT
Date Posted: 12 Nov 2009 at 8:54am
What kind of problem are you having ?  You are returning a 1 if the formula is true but you are not returning a zero if it is false.  Don't you need to add the false condition ?


Posted By: DBlank
Date Posted: 12 Nov 2009 at 9:30am
Note I have had problesm using IIF instead of If-Then in Crystal. Never figured out why so it may not work even with the below. Adding in John's point of the False 0...
Here is IIF:
Iif ( {CnAdrPrf.CnAdrPrf_Type} in ["Good - Busines","Good - Foundation","Good - Home","Good - Seasonal","Home"]
and {CnBio.CnBio_Deceased}="No",1,0)
 
Here is the If- Then
If {CnAdrPrf.CnAdrPrf_Type} in ["Good - Busines","Good - Foundation","Good - Home","Good - Seasonal","Home"]
and {CnBio.CnBio_Deceased}="No" Then 1 else 0


Posted By: tiffnobody
Date Posted: 18 Nov 2009 at 12:27pm
you're right, i forgot to add the false condition!  i realized that after i posted this but thanks so much.  :)



Print Page | Close Window