Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: IF or IIF Statements Post Reply Post New Topic
Author Message
VickiM
Newbie
Newbie
Avatar

Joined: 02 May 2011
Location: United States
Online Status: Offline
Posts: 28
Quote VickiM Replybullet Topic: IF or IIF Statements
     Posted: 01 Aug 2011 at 3:05am
Hi!
 
I always seem to have trouble with this.  If you can help me understand how to string this together, I'd really appreciate it.
 
I have created a formula that works as is:  IF{EMPLOYEE.EMP_STATUS} = "A1" then "Active Full Time"
 
This changes the A1 codes to the actual words Active Full Time just as I need.
 
My problems comes in when I try to also pull in the A2, A3, etc., codes.  What I need to do is have a formula that will change all of my A codes to their appropriate descriptions.
 
How would I write IF{EMPLOYEE.EMP_STATUS} = "A1" then "Active Full Time" or IF{EMPLOYEE.EMP_STATUS} = "A2" then "Active SpWknd Full-Time" or IF{EMPLOYEE.EMP_STATUS} = "A3" then "Active Part Time" etc?
 
Thanks!
 
 
VickiM
IP IP Logged
comatt1
Senior Member
Senior Member
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 337
Quote comatt1 Replybullet Posted: 01 Aug 2011 at 3:10am
take out "or" and put "else"
IP IP Logged
VickiM
Newbie
Newbie
Avatar

Joined: 02 May 2011
Location: United States
Online Status: Offline
Posts: 28
Quote VickiM Replybullet Posted: 01 Aug 2011 at 3:24am
Perfect!  Thank you so much!
VickiM
IP IP Logged
VickiM
Newbie
Newbie
Avatar

Joined: 02 May 2011
Location: United States
Online Status: Offline
Posts: 28
Quote VickiM Replybullet Posted: 14 Sep 2011 at 8:07am
Hi! I'm having trouble with IF Statements again.  This time I want to write a statement like IF{PROCESS_LEVEL} = 3XEC then {HOURLY_RATE} = "".  I keep getting errors.  Can you please tell me what I'm doing wrong.  Thanks!
VickiM
IP IP Logged
CircleD
Senior Member
Senior Member
Avatar

Joined: 11 Mar 2011
Location: United States
Online Status: Offline
Posts: 251
Quote CircleD Replybullet Posted: 14 Sep 2011 at 11:49am
Same solution.You left off the "else". You are giving it a true but you're not defining the false or what to do with it.
IP IP Logged
VickiM
Newbie
Newbie
Avatar

Joined: 02 May 2011
Location: United States
Online Status: Offline
Posts: 28
Quote VickiM Replybullet Posted: 15 Sep 2011 at 2:31am
Hi.  I'm still confused because I don't have an "Else."  I just want the Pay Rate to be a blank if the EEO_SUB_CODE field is 103, 102, 101.  What would the else be?  Is there a way to say that other than using an IF statement?  Thanks! 

Edited by VickiM - 20 Sep 2011 at 5:28am
VickiM
IP IP Logged
VickiM
Newbie
Newbie
Avatar

Joined: 02 May 2011
Location: United States
Online Status: Offline
Posts: 28
Quote VickiM Replybullet Posted: 18 Oct 2011 at 7:56am
Here is what I was able to get to work for me.
 
IIF ( {JOBCODE.EEO_SUB_CODE} in [101, 102, 103] ," " ,  ToText({EMPLOYEE.PAY_RATE}) ).
 
I have another question regarding IF statements. Here is what I want to do.  If HREMPUSF.FIELD_KEY has a 53, then I want a date to appear in the HREMPUSF.D_FIELD.  Otherwise, I want the HREMPUSF.D_FIELD to be blank.  Here is my formula: IF{HREMPUSF.FIELD_KEY} = [53] then totext(Date({HREMPUSF.D_FIELD})) else {HREMPUSF.D_FIELD} ""
 
It gives me a message stating that the "" does not appear to be part of the formula.
 
Would you please tell me what I've done wrong this time?  Thanks!
VickiM
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 18 Oct 2011 at 9:51am
You are not changing the data set (e.g. then HREMPUSF.D_FIELD=""). You are creating a new value (column of data) that is derived from that data (e.g. then "")
 
IF{HREMPUSF.FIELD_KEY} = [53] then totext(Date({HREMPUSF.D_FIELD})) else ""
 
 
Example on your other code:
IIF ( {JOBCODE.EEO_SUB_CODE} in [101, 102, 103] ," " ,  ToText({EMPLOYEE.PAY_RATE}) ).
can also be written as
if {JOBCODE.EEO_SUB_CODE} in [101, 102, 103] then "" else ToText({EMPLOYEE.PAY_RATE})


Edited by DBlank - 18 Oct 2011 at 9:57am
IP IP Logged
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