Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: 0% Formula Issues 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: 0% Formula Issues
    Posted: 23 Oct 2012 at 5:19am
Hi Everyone

I'm trying to set up a generic set of calculations which will work out percentages

The problem i'm facing is, as many of you know, you cannot divide anything by 0 and sometimes there will be 0 in the results thus 0% however I do not know how to get Crystal to understand this without sending up an error message saying it cannot be divide 0

My formula has no errors until it's run and here it is

if ((Sum ({@Educo Availability Pass - Count})) / (Sum ({@Educo Availability - Count}))*100 = 0) then 0 else ((Sum ({@Educo Availability Pass - Count})) / (Sum ({@Educo Availability - Count})))*100

I hoped this would assume that if the first calculation = 0 then show 0 otherwise perform the calculation with those formula (it works if there are actually results so it's not a broken formula)

Does anyone know how to throw out a 0 if the result is a 0 divide?

Thanks in advance

DB
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 23 Oct 2012 at 5:39am
make the if just look at the denominator
if Sum ({@Educo Availability - Count}) = 0 then 0 else (Sum ({@Educo Availability Pass - Count})) % (Sum ({@Educo Availability - Count}))
IP IP Logged
Dbeethekidd
Newbie
Newbie
Avatar

Joined: 12 Oct 2012
Location: United Kingdom
Online Status: Offline
Posts: 7
Quote Dbeethekidd Replybullet Posted: 23 Oct 2012 at 5:54am
DBlank!

Thank you very much for the help

Works perfectly
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.016 seconds.