Only show decimals when there are non zero decimals in Crystal Reports

I have a number field that may be 1.00 which I only want to show 1..
but if its 1.05 I want it to show 1.05

Any ideas??
Michael KatzAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Do you want the values aligned at the decimal point?

 If you use the usual right alignment and simply remove the decimals, you end up with values like this:


Open in new window

Also, do you want to always display 2 decimal places on non-integers, or only display the required number of places?  For example, should 3.5 be shown as 3.50, or just 3.5 ?

 If you want to always display 2 decimal places on non-integers, you can go to the field format, click Customize on the Number tab, click the formula (X+2) button beside Decimals and enter this formula:

if CurrentFieldValue = Truncate (CurrentFieldValue) then

 Rounding would presumably be set to 2 places.  You could use the same formula for Rounding, but it doesn't seem necessary, since you're only hiding the decimals when they're 0.

Michael KatzAuthor Commented:
Awesome answer.. you nailed it..
Try this one
Right click the field
Click the NUMBER TAB
CLick the formula button to the right of Decimals
Enter this formula
If {YourFIeld} = Round ({YourFIeld}) then
Else If {YourFIeld} = Round ({YourFIeld},1) then
Else If {YourFIeld} = Round ({YourFIeld},2) then

Click OK
Set Rounding to 0.001

Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

Michael KatzAuthor Commented:
Which formula button to the right of the decimals??
I'm assuming that that was in response to mlmcc's post.

 It's the same button that I mentioned.  On the Number tab you have to click Customize (mlmcc left that step out), and there's a setting there for Decimals, with a formula (X+2) button beside it.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Thanks James.  Click the CUSTOMIZE option on the NUMBER TAB

Michael KatzAuthor Commented:
Concise and well done... Pretty straightforward from both of these guys...Par for the course with James and mlmcc
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.