It is a useful substitute and a real timesaver compared to complex nested IF formulas. It is more compact and easier to read.

The SWITCH function compares an expression (cell value) against a list of values, and performs the result for the matching value. If a match is not found, a default result can be set.

=SWITCH(expression, value1, result1, [default_or_value2, result2])

*Expression* is the value to be tested against the list of values. This is typically a reference to a cell value such as A2.

*Value1, value2, …* is the value to be compared against the expression.

*Result1, Result2, …* is the action to perform if *Value* is a match to the expression.

*Default* is the action performed if no values match the expression.

Here we can see the strengths and weaknesses of the SWITCH function.

It only refers to the expression once, which is great. While nested IFs will constantly reference the expression in each logical test it performs.

However as a negative, you cannot use logical operators such as >, < or = in the expression. It simply matches the values in its list to an expression, and cannot test if a value is larger or smaller.

In this example, the values in column B are compared against the sequence of values in the SWITCH function – Red, Green and Yellow. Then the resulting discount is returned.

If no matching value is found, then *Not a valid membership* is returned.

=SWITCH(B2,"Red",10%,"Green",14%,"Yellow",18%,"Not a valid membership")

A nested IF formula would have looked like below.

=IF(B2="Red",10%,IF(B2="Green",14%,IF(B2="Yellow",18%,"Not a valid membership")))

Cell B2 is constantly referenced in each IF test. There is no disguising the simplicity of SWITCH in comparison.

This is just 3 tests. If there were many more the difference would have been glaring.

Let’s have a look at the SWITCH function with the ever popular VLOOKUP.

In this example, the SWITCH function returns a different lookup table for each value in the list.

=VLOOKUP(C2,SWITCH(B2,"red",$F$2:$G$6,"Green",$F$9:$G$13,"Yellow",$I$2:$J$6,"Not a valid membership"),2,TRUE)

So here we have created a conditional lookup formula that returns a discount dependent upon the membership they have, and the price ordered.

These two examples demonstrate how useful an addition SWITCH is to the family of logical functions. And although you can’t beat the classic IF function, SWITCH can certainly simplify the more complex ones.

This blog post explores 4 alternatives which are easier, faster and cleaner than the classic nested IF.

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)

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)

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.

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.

=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.

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.

=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.

]]>This tutorial will show you how to display any symbol though, so you could insert a smiley face, hour glass, aeroplane and much more.

The first thing we need to do is find out the letter or number for the symbol we want to insert. Every symbol from the *Wingdings* libraries has an associated letter or number when displayed in a normal written font such as Calibri or Arial.

To find this out; start by inserting the symbol in a cell on your worksheet. Then select that cell and change the font to Calibri, Arial or some other written font.

The letter or number will now be displayed instead. For example, the smiley face symbol is J, and the hourglass is 6. Importantly for this tutorial, we know the thumbs up symbol is C, and thumbs down is D.

The following formula was written in cell D2 of the worksheet shown above.

=IF(C2>=B2,"C","D")

It tests if the value in C2 (this months sales) is greater than or equal to the value in B2 (last months sales). If it is then display C (remember this is the thumbs up symbol), and if not display D (thumbs down symbol).

Now that we have the IF function showing the correct value, all the cells containing the formula need to be formatted in a font such as Calibri to show the symbol.

In the example shown above, the thumbs up symbol is formatted in green, and the thumbs down symbol in red. This is done using Conditional Formatting.

- Select the range of cells containing the symbols.
- Click the
**Home**tab and then**Conditional Formatting**. - Select
**Highlight Cells Rules**and then**Equal To**. - Enter C in the first box and then select a green font colour from the
**Custom Format**options in the second box. Click**Ok**.

- Repeat these steps to display in a red font if the value is equal to D.

Displaying a different symbol based on the values of your worksheet, and applying automatic custom colours can add a creative wow factor to your spreadsheets.

Depending on the kind of data you work with, there are loads of symbols on offer and they may just have your spreadsheets jumping out of the screen.

To insert a happy face in Excel we need to enter a capital **J** and format the cell in a **Wingdings** font. For an unhappy face, it’s a capital **L** formatted in the **Wingdings** font.

The following basic Excel skills demonstrates using this technique to display a happy or unhappy face dependent upon someone’s exam grade. The exam grade is in cell B3 and the smiley face will be inserted into cell C3.

- Click in cell C3
- Write the IF function below and copy it to all the cells where you want the happy face to be displayed. This will display a happy face if 75% or more has been scored.

**=IF(B3>=75%, “J”, “L”)**

- Select the cells and click the
**Font**list arrow on the**Home**tab of the Ribbon - Select
**Wingdings**from the list

- Happy and unhappy faces are shown dependent on the exam grade

Browse our website for more basic Excel skills.

You may already be aware of the Large function. This function is used to return the nth largest value from a list.

To find the 1st and then 2nd, 3rd, 4th and 5th largest values in a list based on multiple criteria, we will need to use the Large function with the Sumproduct function.

The Sumproduct function is a brilliant and incredibly useful function for many situations. It is commonly used to test multiple criteria such as in this example.

The formula below demonstrates finding the 2nd largest value from a list where UK is in column B and London is in column C.

=SUMPRODUCT(LARGE((Data!$B$2:$B$6=”UK”)*(Data!$C$2:$C$6=”London”)*(Data!$E$2:$E$6),2))

Each criteria is placed in parenthesis and the multiply sign is used to ensure each criteria must be met. The plus sign could be used instead to apply OR logic between tests.

Being able to use formulas such as this to analyse data is extremely beneficial. Before we implemented this, they were using 3 PivotTables to drill down the information in sections.

]]>