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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Number Display 2

Status
Not open for further replies.

ricolame

IS-IT--Management
Nov 9, 2005
82
CN
Hi folks,

Would like to seek advice how i should i go about formatting my number figure so that my number can display decimal to 4 places when there is decimal figures with leading zero in front(if less than 1), and if it is not, default to whole number ?

Currently i can only default to leading zero, but if my figure is a whole number, it will show up to 4 decimal places too.

Thank you.

 
Use a formula field,
Code:
 if {value} < 1 
then ToText({value}, 4)
else ToText({value}, 0)

This does not allow for negatives: they would need extra checks.


[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
hi madawc,

For ToText, there's a problem with number less than 1, it shows .xxxx, instead of 0.xxxx

Is there a way in formula to include leading 0 ?
 
0" & ToText({value}, 4)

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
now, if i've to use the figure to sum for summary, i have to change it back to number =)
 
Sum the original database field, not the formula field.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"If you have a big enough dictionary, just about everything is a word"
--Dave Barry
 
Instead of using a formula to convert the number to text, you could instead go to format field->number->customize->decimals->x+2 and enter:

if {table.number} = int({table.number}) then 0 else 4

You would also have rounding set to 4 decimals in the same screen.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top