How to use the IFS function!

Today’s tip – use the IFS function to avoid creating nested IF’s!

The IF function has the format:
IF( condition is true, do something, else do something else). 

Sometimes you want to write something along the lines of  –

“if A = 1, do something, else if A = 2, do this other thing, else if A =3, do this third thing”. 

Writing all this in the IF function gets complicated fast – it looks something like:

IF(A=1, “do x”, IF(A=2, “do y”, IF(A=3,”do z”,”do something else”))).

The above is just complicated. Those nested IF’s are hard to track and truthfully, I wrote the above wrong the first 2 times. This is exactly where the IFS function shines – it allows you to write the above in a much simpler way. It looks something like:

IFS(evaluate condition 1, value if true, evaluate condition 2, value if true…)

So the above equation would be written out as:

IFS(A=1, “do x”, A=2, “do y”, A=3,”do z”)

So simple! Remember this function evaluates conditions left to right, so the minute one condition hits, the remainder of the evaluation is stopped. So for e.g. you could check if A lies in a range in the following way:

IFS(A>90, “do x”, A>80,”do y”,A>70,”do z”…)

Hope that helps you write simpler statements going forward! Have a great week and would love to hear any feedback you might have!