Blog Article:

What is Wrong With the IF Function?

What is Wrong With the IF Function?

To paraphrase George Orwell, never use a long formula when a short one will do.

My early models were almost entirely composed of IF functions. There is nothing really wrong with it, it can be used in many situations and modellers often argue that it is easily understandable. However, it really is long-winded and I believe that around 95% of IF statements can be successfully replaced by one of the following more efficient options:

 

When an on / off switch is needed, use Logical Statements:

e.g. ( F8 > = F9 ) * F10

( F8 >= F9 ) is either TRUE ( =1 ) or FALSE ( =0 )

Therefore, the solution is either F10 or 0.

 

When a comparison is needed, use MAX or MIN:

e.g. MIN ( F29 , MAX ( 0 , F31 ) )

Try writing that one using IF functions.

 

When there is a choice of different options available, use:

Either CHOOSE (recommended for up to 4 options)

Or INDEX with MATCH (recommended for over 4 options).

For more details on these functions, check out this previous blog: CHOOSE and INDEX / MATCH blog

Never use a nested IF (please). It is far too long and error prone.

 

Of course, function choice often comes down to personal preference but some functions are more efficient than others. I encourage modellers only to use IF on the rare occasions when it is really needed. I am sure that George Orwell would have appreciated the clarity.

More from the blog...

To find out more about Camilla Culley’s training courses or to set up a meeting, please get in touch.
+ 44 7932 186481
bookings@camillaculley.com
Camilla Culley © 2025. All Rights Reserved | Privacy & GDPR Policy | Terms & Conditions | Website Design Dorset - Good Design Works