Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: If question Post Reply Post New Topic
Author Message
remdev2
Newbie
Newbie


Joined: 04 Jan 2012
Online Status: Offline
Posts: 4
Quote remdev2 Replybullet Topic: If question
     Posted: 04 Jan 2012 at 5:45am
All
 I need to count the number of records that have a date populated in a field. I tried the following but an error states that "The key word THEN is missing".
 
IF
ISNULL{WHS_Survey.Survey_Submission_Date}
THEN 0
ELSE 1
 
Also, is there a way to add another condition before the IF? 
 
{WHS_Survey.Survey_Submission_Date} IN LastFullMonth
 
Many thanks!!
Pete
 
IP IP Logged
sgtjim
Newbie
Newbie
Avatar

Joined: 23 Aug 2011
Online Status: Offline
Posts: 32
Quote sgtjim Replybullet Posted: 04 Jan 2012 at 6:06am
You are missing parenthesis in your first formula. The IsNull() always puts whatever field in parenthesis.

IF
ISNULL({WHS_Survey.Survey_Submission_Date})
THEN 0
ELSE 1

For your second questions the short answer is yes.

You can have multiple Ifs in one formula. Like so...

If IsNull({table.field}) Then 1

Else If {table.field} In LastFullMonth Then 1

Else If {table.field} > 42 Then 0

Else 0

You can have as many Else If as needed, although I try to keep them to just a few as it gets confusing quick when you have 15 Else If statements.

I hope this helps.
IP IP Logged
remdev2
Newbie
Newbie


Joined: 04 Jan 2012
Online Status: Offline
Posts: 4
Quote remdev2 Replybullet Posted: 04 Jan 2012 at 6:36am
Thanks SJ that did the trick!
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