Tips and Tricks
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Tips and Tricks
Message Icon Topic: IF Formula Post Reply Post New Topic
Author Message
MPLATTS
Newbie
Newbie


Joined: 06 Jan 2011
Location: United Kingdom
Online Status: Offline
Posts: 4
Quote MPLATTS Replybullet Topic: IF Formula
    Posted: 06 Jan 2011 at 10:39am
Hello,
 
I have tried using a IF function in a crystal report but seem to be having problems getting the last part of the formula to work.
 
I'm trying to get the field to work so that if the date in the Updated Field {GL_CODE_LIST.Update} is the same date as that in the Created Field {GL_CODE_LIST.Created} then display some text otherwise return the field value {GL_CODE_LIST.Update}.
 
The formula is listed below,
 
IF ({GL_CODE_LIST.Created} = {GL_CODE_LIST.Updated} THEN "Code Not Updated" ELSE {GL_CODE_LIST.Updated})
 
I can get this formula to work in Excel no problem but I ideally want this to work in the Crystal Report before it's run.
 
I have set up four formulas in the report, detailed below
 
Formula1 - {GL_CODE_LIST.Created}
Formula2 - {GL_CODE_LIST.Updated}
Formula3 - {@Formula1} - {@Formula2}
Formula4 - IF ({@Formula3} = 0 THEN "Code Not Updated" ELSE {GL_CODE_LIST.Updated})
 
So far this hasn't worked either. Every time I have done this it suggests that the final part of the formula has not been defined correctly.
 
I'm sure that this is really simple and doesn't take much to correct, but some advise or guidance would be greatly appreciated?
 
Thanks
 
Mark Platts
Mark Platts, Accountant, Stoke City Council
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 06 Jan 2011 at 11:11am
if {GL_CODE_LIST.Created} = {GL_CODE_LIST.Updated} then "Code Not Updated" ELSE totext({GL_CODE_LIST.Updated},'MM/dd/yyyy')
 
You may need to change the date formating depending on how you want the date to appear.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 06 Jan 2011 at 11:14am
Note that I just simplied your 4 formulas into one but as an FYI I think that your formula 4 error is that you were trying to return 2 different data types on your TEXT and DATE. You have to stick to one and you can convert the date field to text using the totext(field,'format').

Edited by DBlank - 06 Jan 2011 at 11:15am
IP IP Logged
MPLATTS
Newbie
Newbie


Joined: 06 Jan 2011
Location: United Kingdom
Online Status: Offline
Posts: 4
Quote MPLATTS Replybullet Posted: 06 Jan 2011 at 9:40pm
Thanks for this DBlank,
 
I have entered the formula into my report and now when I check the formula it tells me "the formula result must be a boolean"
 
Any more ideas?
 
Thanks
Mark Platts, Accountant, Stoke City Council
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 07 Jan 2011 at 5:53am
i think you are putting the formula in the select expert.
that is only used to selet rows based on a boolean evaluation.
create a new formula field in the object explorer


Edited by DBlank - 07 Jan 2011 at 5:53am
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.035 seconds.