Using the IFS() and SWITCH() Functions to test for more than one condition in Excel 2016
Learn about 2 of the exciting new functions released as part of the Excel 2016 January update
UPDATE: 29th Feb 2016
Since writing this, it’s occurred to me that whilst these functions are available to o365 Personal/Home accounts, they’ve not yet made it onto the Business accounts, which tend to follow a little later (to allow bugs to be ironed out, etc)
If you’re trying to use these, but nothing is happening, sit tight, and hopefully they’ll be available in the coming weeks
Two of the exciting new features released in the January 2016 update of Office 2016, are the IFS() and SWITCH() functions. It’s important to note that only those with an Office 365 subscription will see these functions, and not for those with a fixed-purchase license.
These related functions are going to be very useful for those of you used to using multiple nested IF functions to get your result, as they allow you to test for multiple conditions in one statement.
The concept of a switch statement won’t be alien to everyone – it’s used quite widely in programming languages, and if you’ve been using a more recent version on Excel for a while now, you would probably be able to guess what role IFS play
So what is the difference between the two?
This particular incarnation of SWITCH is fairly tame – they’ve kept its scope fairly narrow, allowing you to test multiple conditions against a single test value. On the other hand, IFS maintains the full flexibility of IF, but allowing you to test multiple conditions
However, I can see SWITCH being an invaluable function – exactly because of its narrow scope.
There are some cases where you can pick between the two, cases where one is a clear better option over the other, and cases where you only really have one option
So here are a few examples;
In this set of examples, I have month numbers 1-12, and want to build some additional fields for them, starting with the name of the month.
Historically, you’d most likely put the month names in a different table, and perform a VLOOKUP. In this simplistic example, that remains a good option, but let’s explore the alternatives.
Using a nested IF statement would never have been a great solution to this, and with good reason. It’s pretty horrific – and until more recently, would not have been possible given there was a limit of 7 nested IF statements.
But, it does the job.
Using IFS, we can continuously test conditions with different results, to get the result in a far simpler statement
As you can see, we’re testing the cell 12 times, each time with a different result based on the value. A good approach, but a little repetitive testing the condition 12 times
This type of requirement is where SWITCH will really stand out;
Here, we’re defining the value we want to test once, at the start. We then go through what we want to do with any given value.
Because we only test once, a SWITCH function will only be useful where you want to test a single value but for multiple conditions.
And, you can of course use the same result for more than one value – here I’m assigning the year Quarter Value, first using IFS, then using SWITCH
Neither approach here is a stand-out ‘winner’ – it would have been nice if SWITCH allowed us to give a group of values to assign to a single result, but could not find a way to do this
(ie, something like this…)
However, what SWITCH does allow you to do is assign an ‘Else’ or Default value.
In this formula, I want to set the winter months (1,2,12) a closed, and the rest of the year as Open
It’s not possible to set a default value with IFS, though you can of course quite easily achieve this effect.
SWITCH also does not allow you to test for ranges, such as GREATER THAN or LESS THAN – it must be an exact value match.
On the other hand, IFS allows you to do this in the same way you could with IF
Going back to the Quarter identifiers;
A further limitation I briefly pointed out before, is that SWITCH can only test against one input value. IFS however can test completely different cells for each part – so if you wanted a statement that combines month and day of the week, you would want to use IFS rather than SWITCH
So there you have it – using the new IFS() and SWITCH() functions gives us some powerful new ways to build conditional statements