How to use the SWITCH function in Excel 2016

If you've spent too much time creating a nested IF formula, you'll love to use the new SWITCH function in Excel. This function saves you time in situations where IFS is needed.

If you've spent too much time creating a nested IF formula (IFS function), you'll love to use the new SWITCH function in Excel. This function saves you time in situations where IFS is needed. Earlier this function was only available in VBA, but recently SWITCH was added in Excel 2016, Excel Online and Mobile, Excel for computers and Android phones. This article will show you how to use the SWITCH function in Excel 2016.

  1. MS Excel - Lesson 15: Harness the power of the Excel function in Excel

SWITCH function syntax

The SWITCH function compares an expression with a list of values ​​and returns the result in the first matching value. If no match is found, it can return the default value.

The structure of SWITCH function is as follows:

 SWITCH (expression, value1, result1, [default or value2, result2], . [default or value3, result3]) 

It has 4 arguments, one of which is optional:

  1. Expression (expression) is a required argument used to compare value1 . value 126.
  2. ValueN is a value used to compare expressions.
  3. ResultN is the value returned when the corresponding valueN argument matches the expression. It must be specified for each valueN argument.
  4. Default is the value returned if no match is found in the valueN expressions. This argument has no corresponding resultN expression and must be the last argument in the function.

Because functions are limited to 254 arguments, you can use up to 126 pairs of value arguments and results.

Compare SWITCH function with IFS function

The SWITCH function, as well as the IFS function, helps define a range of conditions. However, with the SWITCH function you can define an expression and a sequence of values ​​and results, not some conditional statements. With the SWITCH function, you do not need to repeat the expressions again as in the IFS function.

For example, the IFS function below finds the exact states.

Picture 1 of How to use the SWITCH function in Excel 2016

Explanation: cell A2 contains the 85-UT string. RIGHT function extracts the 2 rightmost characters from this string (UT). As a result, the IFS function returns to the right state (Utah). If the rightmost two characters are not equal to UT, TX or OH, the IFS function returns a question mark. Instead of TRUE, you can also use 1 = 1 or something else that is always TRUE.

The SWITCH function below produces identical results but is much easier to read.

Picture 2 of How to use the SWITCH function in Excel 2016

Explanation: if the first argument (RIGHT (A2.2) in this example) is in UT, the SWITCH function returns Uta; if TX returns to Texas; If OH returns to Ohio. The final argument (question mark in this example) is always the default value (if no match is found).

 

Similarly, you can see the following example with the rating system, the SWITCH function looks more compact.

Picture 3 of How to use the SWITCH function in Excel 2016

Picture 4 of How to use the SWITCH function in Excel 2016

See how the SWITCH function works when combined with other functions. Suppose, we have a few days and want to see it quickly is today, yesterday or tomorrow. To do this, we will use the TODAY function to return the serial number of the current day and the DAYS function returns the number of days between two dates.

You can see the SWITCH function works perfectly for this task.

Picture 5 of How to use the SWITCH function in Excel 2016

With the IF function, conversion needs some integration and complexity. So you will be more likely to make mistakes.

Picture 6 of How to use the SWITCH function in Excel 2016

However, it is not always possible to use the SWITCH function in Excel. There are many examples where you cannot use the SWITCH function instead of the IFS function.

Picture 7 of How to use the SWITCH function in Excel 2016

Explain: because here the "<=" and ">" symbols are used in this IFS function, you cannot use the SWITCH function.

The SWITCH function is really a useful function, which saves time and makes fewer mistakes.

I wish you all success!

See more:

  1. These are the most basic functions in Excel that you need to understand
  2. How to combine Sumif and Vlookup functions in Excel
  3. How to use the SUM function to calculate totals in Excel
Update 25 May 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile