Also, here's another hint re common bad use of IF. This is actually draft content from my forthcoming book,
Excel for Superheroes and Evil Geniuses
Use IFERROR() to half the processing cost of error checking
Many of you who cut your teeth on Excel 2003 or earlier are probably still using this to handle errors:
IF(ISERROR(Some_Complex_Formula), Alternate_Formula, Some_Complex_Formula)
A word to the wise:
Don’t. Why? Because Cobbling together an IF and an ISERROR is computationally intensive:
· Excel evaluates the
Some_Complex_Formula bit purely to see if it returns an error or not. It doesn’t even bother to remember the actual answer…it just wants a straight
“Is this an error…Yes or No?
· If there is NO error, then Excel thinks
“Great, no error. Now…what was the answer again? Damn, I didn’t think to store it. *Sigh*. I’ll just work it out again.”. So even though things went
swimmingly well with the
Some_Complex_Formula bit the first time around, it gets evaluated
again, which is damn resource intensive, if not downright
irresponsible.
· If there IS an error, then the Alternate_Formula bit gets evaluated instead. That Alternate_Formula is often just a zero in the case that you’re trying say to work out some percentages, and are trying to avoid a
Divide By Zero error. But even in this very simple Alternate_Formula case, Excel has had to evaluate TWO functions in order to return that zero: an ISERROR check on the
Some_Complex_Formula bit
as well as an IF formula. Again, pretty resource intensive.
Now here’s the thing, my erroneous friends: Microsoft introduced a new formula IFERROR in 2007 which is much more efficient:
IFERROR(Some_Complex_Formula, Alternate_Formula). But for some unfathomable reason,
lots of you still aren’t using it! *Jeff wagging finger*
Tut, tut, you naughty, naughty analysts.
This new IFERROR formula rocks, because it cuts the processing down by more than half:
- the Some_Complex_Formula bit is only ever evaluated once
- The Alternate_Formula bit only gets evaluated if the Some_Complex_Formula bit throws an error.
- Excel only needs ONE function to do all this, as opposed to the ISERROR and IF duo it must contend with in the previous example