Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to format numeric field with null different than zero 1

Status
Not open for further replies.

BobDennison

Programmer
Jul 28, 2010
24
US
I am using Crystal 2008 and my data is coming from a data warehouse. I have a situation where the users want to display a null value as a dash '-' and a zero value as a zero '0'. I have tried using the customize format, but can't mix the 2 formats on the same field. I tried creating a formula to handle, but still no luck. My data needs to look like this:

Actual % Expected %
- 0

Where the "Actual %" is null, and the "Expected %" is 0.

Any suggestions?

Thanks,
Bob
 
Because '-' on its own is not a number, you're going to have to convert the data to a string to display it correctly. The formula will look something like this:

If IsNull({table.field}) then '-'
else ToText({table.field})

If you want to format the number to limit the number of places after the decimal, you can either round it inside the call to ToText or set the decimal places in the call to ToText. See the help in Crystal for more info about how to format numbers when converting them to text.

-Dell

A computer only does what you actually told it to do - not what you thought you told it to do.
 
Thank you for the suggestion. I had tried that, but was not getting the results I wanted. I finally figured out a way to do it though. What I did was go into field format. One the numeric tab I set the default value of zeroes to 0. Then I went to the common tab and wrote code under the Suppress option that says isNull(field). The users are okay with showing a blank value for nulls rather than the '-' as originally requested.

Thank you so much for you help.
Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top