How to use the SWITCH function in Excel 2016
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.
- 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:
- Expression (expression) is a required argument used to compare value1 . value 126.
- ValueN is a value used to compare expressions.
- ResultN is the value returned when the corresponding valueN argument matches the expression. It must be specified for each valueN argument.
- 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.
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.
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.
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.
With the IF function, conversion needs some integration and complexity. So you will be more likely to make mistakes.
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.
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:
- These are the most basic functions in Excel that you need to understand
- How to combine Sumif and Vlookup functions in Excel
- How to use the SUM function to calculate totals in Excel
You should read it
May be interested
- How to fix the error is not down the line in Excelleaving a line in a cell in excel will have different ways such as using a key combination, or a carriage return option in the toolbar. but there are many people who fail to get down in excel.
- How to use the Clipboard Master to save files and documents to the Clipboardclipboard master is the software that will save all file types to clipboard, making copy paste done quickly and accurately.
- How to use the TEXTJOIN function in Excel 2016the textjoin function concatenates text from multiple ranges and / or strings, which includes a delimiter between the connected text value. if the delimiter is an empty text string, this function effectively matches the ranges.
- How to identify phishing emailsaccording to statistics from email security firm mailfrontier, only ... 4% of users are able to identify phishing emails at 100% accuracy rate.
- How to merge text, merge Mail Merge messages in Word 2016mail merge - mixed text or mail merge is a useful feature in microsoft word that allows you to create multiple invitations, thank you messages, notices, file bags, name tags and more stored in the list. , database or spreadsheet.
- How to check typing speed, typing 10 fingersdo you wonder if your typing speed, 10-finger typing is up to the standard? or you are confident your ability to hit your computer at a professional level. the typing speed test websites will tell you the answer.