Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Division by 0 error Post Reply Post New Topic
Author Message
sheriberi
Newbie
Newbie


Joined: 14 Feb 2013
Online Status: Offline
Posts: 6
Quote sheriberi Replybullet Topic: Division by 0 error
     Posted: 15 Feb 2013 at 5:16am
I figured out how to get a percentage of two summarized fields and it works perfectly (with one exception). The formula is:
Sum ({@Payments}, {TABLE_NAME}) / Sum ({@Charges}, {TABLE_NAME}) * 100
The report runs fine but if I use the last page arrow key and go to the last page (and everything is still fine) then I hit the one page back arrow button, I get a msg "Division by Zero" and it opens up the formula with everything but the *100 highlighted. Yes, there are some charges that are zero but I can't have them breaking the report like this, what can I do? Thanks
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 15 Feb 2013 at 7:14am
use an if then statement to account for it
 
if Sum ({@Charges}, {TABLE_NAME}) =0 then 0 else
Sum ({@Payments}, {TABLE_NAME}) % Sum ({@Charges}, {TABLE_NAME})
IP IP Logged
sheriberi
Newbie
Newbie


Joined: 14 Feb 2013
Online Status: Offline
Posts: 6
Quote sheriberi Replybullet Posted: 15 Feb 2013 at 7:34am
that works perfectly, thank you!
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