Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Division by 0

Status
Not open for further replies.

redtoad

Programmer
Jan 28, 2002
51
US
I keep getting this error when running the report for a specific date range."Error in formula . 'WhilePrintingRecords; ' Division by zero.". Error Code: 515"

Here's the calculation formula, I need to deal with the circumstance where DistinctCount = 0. Any insight would be appreciated.

WhilePrintingRecords;
NumberVar RecruitDTF;
NumberVar DCCount := DistinctCount ({MWH_HR.REQ NUMBER}, {@STATus});


IF {@status} = "On Hold" Then
RecruitDTF := 0
ELSE IF {@status} = "Cancelled" Then
RecruitDTF := 0
ELSE IF DCCount = 0 Then
0
ELSE

(RecruitDTF / DistinctCount ({MWH_HR.REQ NUMBER}, {@STATus}) )
 
Change the beginning of your if-then-else as follows:

If {@status} = 0 then 0 else.....

This should effectively check for zeros first, thus avoiding the division by zero error.
Software Training and Support for Macola, Crystal Reports and Goldmine
251-621-8972
dgilsdorf@mchsi.com
 
I think what you actually want to be doing is entering:

If DCCount = 0 Then 0
Else

between your variable assignments and your first IF statement.

I'm sure that's what Dgillz meant.

All the best,

Naith
 
Naith,

You are right, that is what I meant. Thanks. Software Training and Support for Macola, Crystal Reports and Goldmine
251-621-8972
dgilsdorf@mchsi.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top