?
Solved

Divide by zero issue

Posted on 2004-03-25
3
Medium Priority
?
423 Views
Last Modified: 2012-06-21
My report needs a calculated field called Daily Hours. To get this I would do the following in a perfect world.

({pusess.sesshours_no} / {pusess.scheddays_no})

But because the field {pusess.scheddays_no}) has NULL values it falls over saying in can’t divide by zero.

Now I tried     if isnull ({pusess.scheddays_no})  then 0.00 else ({pusess.sesshours_no} / {pusess.scheddays_no})

But Crystal gets in a loop of some sort and crashes. The only way I can make it work is to change all the NULL values to zero and use the following: -

if {pusess.scheddays_no} = 0 then 0.00 else ({pusess.sesshours_no} / {pusess.scheddays_no})

If anyone else has a better idea please let me know
0
Comment
Question by:Matt_Johnston35
  • 2
3 Comments
 
LVL 28

Assisted Solution

by:bdreed35
bdreed35 earned 500 total points
ID: 10678359
Crystal doesn't handle NULL values very well so you have to check for them if they are a possiblility in your data.

Since you have converted NULLS to the default, the way you handling it is the best way you can.

I would do it the same way.
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 500 total points
ID: 10680372
I would have expected
if isnull ({pusess.scheddays_no})  then 0.00 else ({pusess.sesshours_no} / {pusess.scheddays_no})

to work.  If it isn't I can't think of a better way than what you did but be careful that can cause other problems.

mlmcc
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 10683522
Glad I could help

mlmcc
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Integration Management Part 2
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month15 days, 12 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question