Evaluating division by zero
=IF(OR(C2=0,D2=0),0,D2/C2)
If C2 and D2 are current year and prior year costs and either one of them
are zero, then the formula will return a zero, other wise it will divide
current year by prior year.
"Shams" wrote:
Hi,
Thanks for your reply. That's what I did exactly..the IsERROR
function...but i realized something else....we may have discontinued a
product in this year..so no cost in current year but $$ in prior year...now a
formula that evaluates (curr Yr/Prior Year)-1 will return -100%..how do i
also avoid this within the same formula? i.e. evaluate zero if prior period
is zero and also evaluate to zero if curr. period is zero...
I thought, I could do an IF(or function such as:
IF(or(af1=0,aj1=0),0,((aj1/af1)-1)))
but this is not working
Any tips is appreciated
"BoniM" wrote:
Using the iserror function:
=IF(ISERROR(C2/D2),"",C2/D2)
with C2 being your prior years cost, and D2 this years. This will return a
blank cell for new products. You could have it return 100% if you changed ""
to 1.
You could also simply check to see if you had a prior year cost:
=IF(D20,C2/D2,"")
and don't do the division unless you did.
Again - to get a 100% result:
=IF(D20,C2/D2,1)
Hope this helps...
"Shams" wrote:
Folks,
I am simply trying to calculate % Change in Cost b/w two periods. Now, we
may have introduced a new product in the new period which would have zero
cost in the prior period. Therefore, a simple % change calculation for this
product will yield a #DIV/0! error.
I want to be able to copy down a formula that will first evaluate for
ISerror conditions by inputting a zero value and secondly evaluate for all
others by just doing a % change. I am thinking of combining if(iserror(..
with nested if functions...just not sure about the syntax. Any help is
greatly appreciated
|