?
Solved

Divide by zero issue

Posted on 2004-03-25
3
Medium Priority
?
420 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

765 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