Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formula for percentage Post Reply Post New Topic
Author Message
DawnBB
Newbie
Newbie
Avatar

Joined: 23 Jul 2009
Online Status: Offline
Posts: 2
Quote DawnBB Replybullet Topic: Formula for percentage
     Posted: 23 Jul 2009 at 3:02pm
I need help writing a formula in Crystal.

If the quantity is a whole number, I want the whole number to display with no decimal places.

If the quantity contains a fraction, then I want the fraction to display.

For instance,
If quantity = 5 then display 5 ---- not 5.00
If quantity = .25 then display .25
If quantity = 6.75 then display 6.75

Thank you.

Dawn
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 24 Jul 2009 at 7:06am
format your value as text and display it as text.  I don't think that this can be done as a number as there is no conditional formatting for the number.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 24 Jul 2009 at 7:39am

Try this:

Right click on the field and select Format Field.
Select the Number tab
click on Customize
UNder the Number Tab add a formula to the Decimals as:
if right(totext({table.numberfield},2),2)="00" then 0 else 2
 
IP IP Logged
DawnBB
Newbie
Newbie
Avatar

Joined: 23 Jul 2009
Online Status: Offline
Posts: 2
Quote DawnBB Replybullet Posted: 24 Jul 2009 at 11:56am
DBlank - GENIUS!  It worked perfectly .... and your instructions were perfect.  Thank you, very  much.
Dawn
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 27 Jul 2009 at 6:03am

I guess I stand corrected...there is conditional formatting for numbers. :(

Boy, I have looked at that tab, thousands of times and it never registered that there were formula buttons there.
 
Silly Me.


Edited by lockwelle - 27 Jul 2009 at 6:05am
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