Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Percentage Miscalculation Post Reply Post New Topic
Author Message
Dbeethekidd
Newbie
Newbie
Avatar

Joined: 12 Oct 2012
Location: United Kingdom
Online Status: Offline
Posts: 7
Quote Dbeethekidd Replybullet Topic: Percentage Miscalculation
     Posted: 21 Nov 2012 at 10:40pm
Hi All

I'm having an issue with a calculation which seems to think that is you divide 0 by 100 you should get 100% which is most certainly not the case

My formula reads

if Sum ({@Catering Count}) = 0 then 0 else (Sum ({@Catering Pass})) % (Sum ({@Catering Count}))

The Catering Count = 1 and the Catering Pass = 0

Now I know either way the answer should be 0% or some kind of error saying you can't divide 1 by 0 but instead I get 100%

Any ideas/help/explanation would be greatly appreciated

Thanks again

DB
IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 21 Nov 2012 at 11:59pm
Hi
 
As we all know 0 divide by any value is zero only there will not be any number.
 
Try the following :
 
if Sum ({@Catering Count}) <> 0 then 
( Sum ({@Catering Pass}) / Sum ({@Catering Count}))*100
else
0
 
 
Thanks,
Sastry
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