cancel
Showing results for 
Search instead for 
Did you mean: 

Format decimal places

05-27-2008 8:11 AM
2147 views 4 comments
0 Likes
SAP Managed Tags
Subscribe

Post Author: Bandi

CA Forum: General

Using Crystal XI (v 11.0.0.2442)

Hopefully there is a simple obvious answer to this one... I need to have a numeric field set up so that it displays decimal places ONLY if the value is not an integer.

ie: I have 2 records with the values 24 and 24.945. I want these 2 values to display exactly like that....

Using only the formatting options for the field I can have them display as either 24.00 and 24.945 OR 24 and 25.

Just to complicate things, I set up a formula as follows... (Basic syntax shown... also tried crystal syntax)

if int() = then formula = ToText(, "#")else formula = ToText(, "#.####")end if

As far as I understand, this should have produced the results I wanted.... 24 and 24.945, however, it produces the results 24 and 24.95! WTF? Why is it rounding the second value to 2dp. This is a text formula so I dont have the ability to set any formatting which may have caused the problem.

Can anyone shed some light on this issue and show me the way forward?

Thanks, Anthony

0 Likes

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Likes

Post Author: Bandi

CA Forum: General

Thanks for the suggestion. Unfortunatly it didn't resolve the formatting issue I'm having.

formula = ToText(, "#.####", 3) produces the result 24.9450 where I only want to see 24.945. For the number 24.9, it produces 24.9000 -


If possible can someone please confirm the 2 following behaviours... 1) Specifying a formula as formula = ToText(, "#.####") where Myfield is a decimal value with more than 2 decimal places, returns the value automatically rounded to 2 decimal places, even though the formatting indicates 4 decimal places should be shown

2) Specifying a formula as formula = ToText(, "#.####", 10) where Myfield is a decimal value with 1, 2 or 3 decimal places returns the value padded with trailing 0's out to 4 decimal places (ie: 24.9 becomes 24.9000) even though the # should mean that that position is left empty if no decimals exist in that position.

Thanks heaps Anthony

Former Member
0 Likes

Hi,

You will need this field set up twice - once for no decimal, once with decimal. Activate the suppression option for both fields based on the value of the field (i.e. whether there are decimals or not).

Hope this helps,

Heather

Former Member
0 Likes

Post Author: SKodidine

CA Forum: General

Try:

formula = ToText(), "#.####", 3),

Former Member
0 Likes

Post Author: Bandi

CA Forum: General

P.S.

If I change the last formula line to

formula = ToText(), "#.####", 10), it produces 24.9450. It now gets the number correct, but ignores the fact I'm using a # for the formatting and puts a trailing 0 in. * SIGH*