Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

division by zero

division by zero

division by zero

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!!

RE: division by zero

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.


DecisionFirst Technologies - Seven-time SAP BusinessObjects Solution Partner of the Year

RE: division by zero

that worked! Thank you!

RE: division by zero

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!!!

RE: division by zero

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close