Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Division By Zero 4

Status
Not open for further replies.

fhurmuzlu

Programmer
Nov 16, 2004
52
US
At our work we use Crystal reports 6, when I
creat 1 report I`ll get a "division by zero"
error message. The formula is:
{vw_Potential_Summary.Annualized_Sales}/
{vw_Potential_Summary.Potential_Purchases}
This should work, what does a "division by
zero"" means, what`s wrong with this formula.
 
Simply stated, you cannot divide by zero. It's a mathematical NO-NO

Change your formula accordingly.

if {vw_Potential_Summary.Potential_Purchases} > 0 then
{vw_Potential_Summary.Annualized_Sales}/
{vw_Potential_Summary.Potential_Purchases}
else
0
 
The 1st line in the formula should say .....
"IF {vw_Potential_Summary.Potential_Purchases}= 0 THEN 0 ELSE;"

{vw_Potential_Summary.Annualized_Sales}/
{vw_Potential_Summary.Potential_Purchases}


If {vw_Potential_Summary.Potential_Purchases}is a string then the zeros should be in quotes.


DataDog
'Failure Is Not An Option'
 
For an overblown explanation of why you can't divide by zero, go here.

In your case, at some point during the execution of the report, {vw_Potential_Summary.Potential_Purchases} is zero, hence the error. You can modify your formula a bit to test for zero before the division takes place:

if {vw_Potential_Summary.Potential_Purchases} = 0 then
0
else
{vw_Potential_Summary.Annualized_Sales}/{vw_Potential_Summary.Potential_Purchases}

-dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top