Solved

Divide by zero issue

Posted on 2004-03-25
3
417 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 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

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…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

730 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