Solved

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

Posted on 2014-10-28
7
1,023 Views
Last Modified: 2014-11-17
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??
0
Comment
Question by:Mikeyman_01
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 35

Expert Comment

by:James0628
ID: 40408927
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:

   1
   2
3.50
   4
5.25
   6

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
  0
else
  2


 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.

 James
0
 

Assisted Solution

by:Mikeyman_01
Mikeyman_01 earned 0 total points
ID: 40408942
Awesome answer.. you nailed it..
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 40408961
Try this one
Right click the field
Click FORMAT FIELD
Click the NUMBER TAB
CLick the formula button to the right of Decimals
Enter this formula
If {YourFIeld} = Round ({YourFIeld}) then
   0
Else If {YourFIeld} = Round ({YourFIeld},1) then
   1
Else If {YourFIeld} = Round ({YourFIeld},2) then
   2
Else
   3

Click OK
Set Rounding to 0.001

mlmcc
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:Mikeyman_01
ID: 40411735
Which formula button to the right of the decimals??
0
 
LVL 35

Accepted Solution

by:
James0628 earned 250 total points
ID: 40411751
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.

 James
0
 
LVL 101

Assisted Solution

by:mlmcc
mlmcc earned 250 total points
ID: 40411820
Thanks James.  Click the CUSTOMIZE option on the NUMBER TAB

mlmcc
0
 

Author Closing Comment

by:Mikeyman_01
ID: 40446867
Concise and well done... Pretty straightforward from both of these guys...Par for the course with James and mlmcc
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question