Skip to content

How to Use Excel SWITCH Function?

Ads
Listen to this article.
SWITCH FunctionPin
SWITCH Function

Sometimes, we want to evaluate each value in the input range and get the result based on a given condition. In that case, we suggest you use the Excel SWITCH function. It helps to evaluate each value against a list of values in the range and returns the first matching value. In case there are no matches found, this function returns the default value. This post will let you understand how to use this function on your worksheet with various scenarios.

With the help of the given syntax and examples, you can understand how to use the Excel SWITCH function on your worksheet and quickly finish your work. Get an official version of MS Excel from the following link:

https://www.microsoft.com/en-in/microsoft-365/excel

Excel-SWITCH-FunctionPin
Excel-SWITCH-Function

Syntax

  • Here, you will see the syntax of the SWITCH function.
  • To apply this function on your spreadsheet, you must select a cell and enter the formula in the following format.
  • Once you enter the formula, click the Enter button to get the result.

=SWITCH(expression, val1/result1, [val2/result2], …, [default])

Parameter Description

  • expression – It is the input value that needs to be checked with the given expression.
  • val1/result1 – This is the first value or result pair.
  • val2/result2 – It is an optional one. This represents the second value and result pair.
  • default – This is also an optional one. We can set a default value to display when no match is found in the range.

What Will SWITCH Function DO?

SWITCH function in Excel is a built-in feature. This logical function helps to run multiple conditions and returns the value if it founds the first match. It is similar to the IF Function. The major difference is that IF runs only one command, but SWITCH runs multiple commands and returns a single value.

For example, we have a list of student names and their grades based on their academic performance. And we need to categorize them as “Excellent“, “Good“, and “OK” based on the grades that they have achieved.

Student GradesPin
Student Grades

From the above table, we have to categorize the students as “Excellent” who all got a grade of “O.” And need to represent Grade A as “Good” and Grade B as “OK.” If the student’s grade satisfies the given conditions, then it returns any of the three values (Excellent, Good, OK). If none of the given grades are found, then it returns “?.” In order to get the output, enter the following formula in the cell, as shown in the below screenshot.

=SWITCH(C3,”O”,”Excellent”,”A”,”Good”,”B”,”OK”,”?”)

Enter the formulaPin
Enter the formula

Now, click on the Enter button to execute it and get the result. To fill the remaining cells in the range, you have to drag down the first cell to the last cell in the range. It will quickly autofill the results based on the given input values.

OutputPin
Output

From the above scenario, we helped you to know the working nature of the Excel SWITCH function. In case, you want to learn this with simpler examples, move to the upcoming portion.

Alternate Examples

Here in this section, we have shown you simple examples to make you understand the Excel SWITCH function.

  • Initially, you have to launch your Excel workbook with the data on your computer.
  • Here we come up with a range of input values. We need to check them with multiple conditions using the SWITCH function. In the following range, we can categorize the color “Red” as 1, “Blue” as 2, and “Green” as 3.
Input RangePin
Input Range
  • Now, we have to enter the formula in a cell to get the result. The SWITCH function will return a result based on the first matching value in the range.
Type the formulaPin
Type the formula
  • Once you have gotten the first result, just drag down that cell to autofill the remaining cells in the range, as shown in the below image.
ResultPin
Result

With the help of these simple examples, you might understand the usage of the SWITCH function in your spreadsheet.

Citations

We all know that the SWITCH function is a logical expression in programming languages. In Excel, we can use the SWITCH function to perform various tasks based on different conditions. We have understood the purpose of SWITCH logical expression with the help of the sites: Switch Statement[1] and Use SWITCH Case[2].

  1. https://en.wikipedia.org/wiki/Switch_statement
  2. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch

Verdict

Thus, we have known the purpose of the SWITCH function in Excel with proper scenarios. By using this function, we can easily evaluate the given expression against a list of values. To learn more about Excel functions, then visit our webpage, Aawexcel.com.

If you want to know what people think about this SWITCH Function of Excel, then we suggest you look for it on the Quora interaction webpage. From where you can get to know more regarding the Excel SWITCH function. Here, we have provided the link to Quora’s official website.

Video Tutorial

The following video will show you the procedure to apply the SWITCH Function and how to use it effectively in your spreadsheet.

Excel SWITCH Function Video

Also See:

Tags:

Leave a Reply

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

Share to...