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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dividing by zero error

Status
Not open for further replies.

dannyb29

Technical User
Nov 10, 2010
90
GB
Hi Guys,
Can you help please. Crystal is having problems dividing by 0. Is there anything I can do?

I have 3 formulas:
First one: @null
This formula is blank

Second One: @Del Received
if {AVBRecordTypes.Description}= "Delivery Acceptance from PDA" then
{AVBTransactionLog.TxnId} else
{@null}

Third One:mad:Del Received by shift
DistinctCount ({@Del received}, {Users.LoginName})/DistinctCount ({@Count Shift}, {Users.LoginName})

Many Thanks
Danielle
 
Chnage this one

Third One:

@Del Received by shiftDistinctCount ({@Del received}, {Users.LoginName})/DistinctCount ({@Count Shift}, {Users.LoginName})

to

If DistinctCount ({@Count Shift}, {Users.LoginName}) = 0 then 0 else
@Del Received by shiftDistinctCount ({@Del received}, {Users.LoginName})/DistinctCount ({@Count Shift}, {Users.LoginName})

whenever you use a division formula always do a zero test.

Ian
 
Hi Ian,
Thank you for this but the code seems to be wrong. ;{

Third One:
//@Del Received by shift - (This line isnt a part of the code. This is the name of the formula)

The code for @Del Received by shift starts here:

DistinctCount ({@Del received}, {Users.LoginName})/DistinctCount ({@Count Shift}, {Users.LoginName})

Would you be so kind to review your code.

Many Thanks Danielle

 
Dannyb,

Ian simply had a copy-paste slip... happens to all of us.
Code:
If DistinctCount ({@Count Shift}, {Users.LoginName}) = 0 then 0 else 
DistinctCount ({@Del received}, {Users.LoginName})/DistinctCount ({@Count Shift}, {Users.LoginName})


What the formula does is looks to see if your denominator is zero (in this case if {@Count Shift} is zero), if so, return zero for the formula (as you cannot divide by zero) else do the calculation.

Cheers!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
Thank you so much guys! I really aprreciate your help!
And mIke your signature statement is inspirational!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top