Solved

Divide by zero issue

Posted on 2004-03-25
3
412 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 125 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 100

Accepted Solution

by:
mlmcc earned 125 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 100

Expert Comment

by:mlmcc
ID: 10683522
Glad I could help

mlmcc
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now