Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Help with Decimals Post Reply Post New Topic
Author Message
FrnhtGLI
Senior Member
Senior Member
Avatar

Joined: 22 May 2009
Online Status: Offline
Posts: 347
Quote FrnhtGLI Replybullet Topic: Help with Decimals
     Posted: 16 Nov 2009 at 8:56am

I have a number coming through in a string field. The field is being used in a number variable so it can be added to like fields. The sum is the only field being displayed in a faux detail section(group footer is being used to display the sum so it can be calculated on the real detail section).

 
The number varies in how many decimal places it has, but the most is 4. I want to dispaly however many decimal places the sum field has, but only however many is needed. If the field is 60.0000 then I only want 60. If 60.0100, then only 60.01 and so forth.
 

Anyone have an idea of how to accomplish this?



Edited by FrnhtGLI - 16 Nov 2009 at 8:56am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 16 Nov 2009 at 11:14am
There is probably an elegent solution but this should work in the interim:
Right click on the field and select format field
Click on teh NUmbers tab
Click on Customize
Click on the formula next to Decimals
add this formula:
if right(totext({table.numberfield},4),4)="0000" then 0 else
if right(totext({table.numberfield},4),3)="000" then 1 else
if right(totext({table.numberfield},4),2)="00" then 2 else
if right(totext({table.numberfield},4),1)="0" then 3 else 4
IP IP Logged
FrnhtGLI
Senior Member
Senior Member
Avatar

Joined: 22 May 2009
Online Status: Offline
Posts: 347
Quote FrnhtGLI Replybullet Posted: 17 Nov 2009 at 5:09am
well, I wasn't looking for elegance, just functionality and that worked. Thanks!Clap
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