Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Simple Formula? Post Reply Post New Topic
Author Message
sdibble
Newbie
Newbie


Joined: 19 May 2008
Online Status: Offline
Posts: 2
Quote sdibble Replybullet Topic: Simple Formula?
     Posted: 19 May 2008 at 9:25am
Hello all.... thank in advance for any help.  I have a simple formula or so it would seem... I want to check a numeric field
- if it is blank I want to return "missing data"
- if it is = 0 I want to return "missing data"
- else perform a calculation
 
 
This is the formula I am trying to use... but as I am sure you know... I get an error that it expects a string wwhere the calculation takes place.  Help! 
 
IF {TBL_COMPANY.CUST_NODHW_1Q_082920825} = 0 then UpperCase ("missing data")
else
{TBL_COMPANY.CUST_NODHW_1Q_082920825} + {TBL_COMPANY.CUST_NSHW_1Q_082741358}
 
Thank you


Edited by sdibble - 19 May 2008 at 9:39am
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 19 May 2008 at 3:35pm
Try this:
 
If IsNull({TBL_COMPANY.CUST_NODHW_1Q_082920825}) then "MISSING DATA"
else if {TBL_COMPANY.CUST_NODHW_1Q_082920825} = 0 then "MISSING DATA"
else To_Text({TBL_COMPANY.CUST_NODHW_1Q_082920825} + {TBL_COMPANY.CUST_NSHW_1Q_082741358})
 
If you need to format the result of the To_Text, look at the function in the Help to find the number format strings.
 
-Dell
IP IP Logged
sdibble
Newbie
Newbie


Joined: 19 May 2008
Online Status: Offline
Posts: 2
Quote sdibble Replybullet Posted: 20 May 2008 at 8:14am
Works great... with one twist.  How can I conditionally format that, so that when it will return an actual number?
 
In otherwords... if it can be calulated ( the fields are > 0 and present) I would like to be able to return a number rounded up to the nearest 1 with the decimals suppresed.... or "MISSING DATA" if it is not caclulable (as per the formula).
 
 
Thanks so much!
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 20 May 2008 at 10:59am
You can't - a single formula can only return one data type.  You have both string and number, so it has to be a number.
 
However, if you need the number elsewhere, I would create a formula something like this:
 
if not IsNull({TBL_COMPANY.CUST_NODHW_1Q_082920825}) and not IsNull({TBL_COMPANY.CUST_NSHW_1Q_082741358}) then
{TBL_COMPANY.CUST_NODHW_1Q_082920825} + {TBL_COMPANY.CUST_NSHW_1Q_082741358}
else
0
 
To format the number in your string result, like I said in my first post, do a search in the Help for To_Text and look at the information for formatting numbers.
 
-Dell
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