Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Number format Post Reply Post New Topic
Author Message
Latte
Newbie
Newbie


Joined: 24 Aug 2010
Online Status: Offline
Posts: 9
Quote Latte Replybullet Topic: Number format
     Posted: 21 Mar 2011 at 4:33pm
Hello,
 
I have a 'quanity' column which rounds to the nearest whole number.
 
Eg. 0.5 would be rounded up to 1.
 
Does anyone know how to customise it/write a formula that formats it so that if it is a whole number, it stays a whole number (ie. 1000, not 1000.00) but if it is a decimal, it stays a decimal?
 
Many thanks in advance!
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 22 Mar 2011 at 2:50am
Place field on report, right-click field --> format field
number tab --> customize
Specify a formula for the number of decimals

Check whether the number is decimal or not. There may be more sophisticated mathematical methods, but here is one way:


if {number} - truncate({number}) = 0 then
   0
else
   2


truncate(number) chops off the decimal values and basically gives you a whole number.
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