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!

Divide by zero - can't figure out

Status
Not open for further replies.

keat63

Technical User
Nov 12, 2010
44
GB
Guys.

I'm trying to create a simple report based on what a customer paid vs the cost of the item, then showing this as a percentage profit.
However I'm getting divide by zero errors.
Ive tried if (xxx) = 0 then 0, but i'm guessing that i have zero's in multiple fileds.

({INVTRAN.VALUE} - {COSTS.PRICE} / {COSTS.PCAT} * {INVTRAN.QTY}) / ({INVTRAN.VALUE})*100

if it helps

costs.pcat is the price we pay per 100 or 1000 etc, i guess the others are self explanatory.

Is it possible to but a "If [xxx] = 0 then 0" for all fields ?
 
I may have actually figured it out.

if {INVTRAN.VALUE} = 0
or {COSTS.PRICE} = 0
or {COSTS.PCAT} = 0
or {INVTRAN.QTY} = 0
or {INVTRAN.VALUE} = 0
then 0
else

It's messy, but appears to be running.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top