4 Alternatives to Nested IF Formulas

0 Flares Filament.io 0 Flares ×

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.

=IFS(B2="Platinum",110,B2="Gold",90,B2="Silver",65,B2="Bronze",40)

The IFS function from Excel 2016

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.

=VLOOKUP(B2,$F$4:$G$7,2,FALSE)

Using VLOOKUP instead of a nested IF

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.

VLOOKUP for range lookup

A nested IF approach could look like this.

=IF(A2>=90%,"A",IF(A2>=80%,"B",IF(A2>=70%,"C",IF(A2>=60%,"D",IF(A2>=50%,"E","F")))))

Or even like this.

=IF(AND(A2>=90%,A2<=100%),"A",IF(AND(A2>=80%,A2<90%),"B",IF(AND(A2>=70%,A2<80%),"C",IF(AND(A2>=60%,A2<70%),"D",IF(AND(A2>=50%,A2<60%),"E","F")))))

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.

=VLOOKUP(A2,$E$4:$F$9,2,TRUE)

Much simpler.

This is a range lookup, so it is essential that the first column of the lookup table (column E) is in ascending order.

VLOOKUP to return from a range

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.

Using the CHOOSE function

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.

=IF(A9=1,A3,IF(A9=2,D3,IF(A9=3,G3,IF(A9=4,J3))))

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.

=CHOOSE($A$9,A3,D3,G3,J3)

I hope you found these nested IF alternatives useful. Check out these other Excel formula tutorials.

Leave a Reply

Your email address will not be published. Required fields are marked *