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.
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:
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 "" 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:
ncG1vNJzZmismaXArq3KnmWcp51ktbDDjK2mZq2jmnq1tMRmqrChpJi1brLUp5qtoZ%2Bjeqq6jJ6vnJ2cYn9xfZU%3D