Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Division by a zero, how do you control for it? Post Reply Post New Topic
Author Message
rkorb
Newbie
Newbie
Avatar

Joined: 04 Sep 2009
Location: United States
Online Status: Offline
Posts: 31
Quote rkorb Replybullet Topic: Division by a zero, how do you control for it?
     Posted: 04 Sep 2009 at 4:30pm
Besides good data, what is a good way to control for division by a zero not crashing your report when it happens in a formula?  Thanks for your help!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 04 Sep 2009 at 7:19pm
IMO it is good practice to always use an "if then" when dividing unless you are sure that the results will allways have a value >0 whenever the report is run
...
if denoninator =0 then 0 else numerator/denominator
e.g.
if Sum(employee.sales)=0 then 0 else
Sum(employee.sales,employee.id) / Sum(employee.sales)


Edited by DBlank - 04 Sep 2009 at 7:21pm
IP IP Logged
rkorb
Newbie
Newbie
Avatar

Joined: 04 Sep 2009
Location: United States
Online Status: Offline
Posts: 31
Quote rkorb Replybullet Posted: 08 Sep 2009 at 11:26am
Thanks again! I knew there was some way to help control for it!
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