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 Mike Lewis 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 1

Status
Not open for further replies.

jschill2628

Programmer
Nov 3, 2009
156
US
Hello, I have a crystal report that runs based on time frame and state. The problem come from a formula I have within the report:
totext(sum({@precursor count})/sum({@Serious Event Count}),0,"")

this is a great formula, but when I run it for a particular time frame it gives me the following error:
Error in File Safety- First Events Summary: Error in formula serious to Precursor 2: 'totext(sum({@precursor count})/sum({@Serious Event Count}),0,"")' Division by zero. Details: errorKind

So I am trying to fix it with the following formula:
if isnull ({@Serious Event Count}) or ({@Serious Event Count}) = 0 then 0 else
totext(sum({@precursor count})/sum({@Serious Event Count}),0,"")

except I the following error: "A number is required here"- highlighting the last line in the formula.

Can someone help me with my formatting.

Thanks in advance!!
 
Change the formula to this:

if isnull ({@Serious Event Count}) or ({@Serious Event Count}) = 0 then "0" else
totext(sum({@precursor count})/sum({@Serious Event Count}),0,"")

Your "Then" and "Else" clauses have to return values of the same type - in this case either number or string, not one of each.

-Dell

DecisionFirst Technologies - Seven-time SAP BusinessObjects Solution Partner of the Year
 
I do have a question.....with my new formula:

if isnull ({@Serious Event Count}) or ({@Serious Event Count}) = 0 then "0" else
totext(sum({@near miss count})/sum({@Serious Event Count}),0,"")


it seems to be pulling only zero. For example if I have 9 serious safety events, and 27 near miss events, then my ratios should be 1 and 3 respectively, but I am getting 1 and 0. It works if I comment out the first line, but then if I have a situation where I am dividing by zero, then i get an error, so what should I do, I feel like I should rearrange the formula some how, but I am not getting it. I have played with this for hours, and I am getting the same thing. can some one please help. I need the formula to give me the number, and if the number is being divided by zero, then give me a zero.

Thanks in advance!!!
 
Another time, you should start a new thread for a new topic.

For now, do two new formula fields showing sum({@near miss count}) and sum({@Serious Event Count}). Display them in a temporary new section. You'll probably find the values are not what you thought they were.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 2008 with SQL and Windows XP [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top