Nested IF formulas are extremely useful for complex decision making on a spreadsheet, but they can also be long, messy and convoluted.
This blog post explores 4 alternatives which are easier, faster and cleaner than the classic nested IF.
Watch the Video
1. The IFS Function (Excel 2016 + only)
Lets start with a function that is new from Excel 2016 called the IFS function.
This function was introduced to condense and simplify the task of writing nested IFs. You can avoid all of those brackets that come with opening and closing multiple IF functions.
In the example below we used an IFS function to calculate the price for each membership type. There are four types of membership (platinum, gold, silver and bronze).
The IFS function tests cell B2 for each membership type and applies the correct price.
2. Using VLOOKUP for an Exact Match
I believe an even better alternative to the IFS function for this scenario would be a lookup.
Now you can use any lookup formula that you like to achieve this. In this example I will use VLOOKUP.
By creating a lookup table (F4:G7 below) we are able to use the following VLOOKUP function to search for each membership and return the correct price.
This is very compact and easier to adapt in the future. If a membership price changes, you can just change the lookup table. There is no need for someone to have to edit the formula, which you or your colleagues may not be comfortable doing 10 months from now.
3. Using VLOOKUP for a Range Lookup
In this alternative formula we use VLOOKUP again, but this time for a range lookup.
Take the example below where we have a list of exam scores and we need to assign a grade for each score.
A nested IF approach could look like this.
Or even like this.
Now these formulas work perfectly. However they are complex and messy. And unless your trying to impress someone with big complex looking functions, there are better ways.
With the lookup table set up in range E4:F9 we could use this VLOOKUP function.
This is a range lookup, so it is essential that the first column of the lookup table (column E) is in ascending order.
4. The Fantastic CHOOSE Function
This last alternative to the nested IF formula is a bit of a secret function. Many Excel users will never have even heard of the CHOOSE function.
This function will perform an action based on a specific index number. And that makes it perfect for use with form controls.
So in this example I have an interactive chart being driven from a combo box control.
The image below may look a little messy. Typically some of this data would be hidden or stored on separate sheets. It is all on one sheet here to get a better idea of how it works.
The first 7 rows have data of the top goal scorers from 4 different football leagues in the 2016-17 season. A combo box is on the left and is linked to cell A9. A selection from the 4 leagues in the combo box will produce index number 1, 2, 3 or 4 in cell A9.
Formulas are in cells D9 and range D11:E15 returning the correct data for the chart from the combo box selection. This is easier explained in the video.
Now in the cells mentioned above we could use a nested IF like below. This is the nested IF from cell D11 which returns the name of that leagues top goal scorer.
Or we could use this awesome and simple little CHOOSE function. It checks the index value in cell A9 and then returns the relevant information from its list.
I hope you found these nested IF alternatives useful. Check out these other Excel formula tutorials.
- Excel formula to find the least frequent value
- Formula to match records from different worksheets
- Tips for troubleshooting formulas