Table of Contents
Want to know How To Master the SWITCH Function in Excel?
*** Watch our video and step by step guide below with free downloadable Excel workbook to practice ***
What does it do?
Matches multiple values and returns the first value that has a match
Formula breakdown:
=SWITCH(expression, value1, result1, [value2 / default, result2], …)
What it means:
=SWITCH(value to check, value to match against, result to return, [succeeding values to match or the default value if nothing gets matched], …)
If you have multiple values to check, we can use Excel’s SWITCH Formula! It allows us to specify multiple values to check, then the SWITCH Formula will look for the first value that gets matched!
Let us try it out on a simple ratings table (e.g. 1 = Bad, 2 = Average, 3 = Great), then we will create a SWITCH Formula that will simulate the exact same logic of the table!
I explain how you can do this below:
STEP 1: We need to enter the SWITCH function in a blank cell:
=SWITCH(
STEP 2: The SWITCH arguments:
expression
What is the value to check?
Select the cell containing the rating that you want to translate to the correct description
=SWITCH(G8,
value1, result1
What is the first lookup value and value to return if it is matched?
Let us start from the first value of the rating table. If the value is 1, then the description is “Bad”
=SWITCH(G8, 1, “Bad”
value2, result2
What is the second lookup value and value to return if it is matched?
Let us start from the second value of the rating table. If the value is 2, then the description is “Average”
=SWITCH(G8, 1, “Bad”, 2, “Average”,
value3, result3
What is the third lookup value and value to return if it is matched?
Let us start from the third value of the rating table. If the value is 3, then the description is “Great”
=SWITCH(G8, 1, “Bad”, 2, “Average”, 3, “Great”,
default
What is the default value to return if nothing gets matched?
We want to show the value “Unknown”, if an unknown rating is specified.
=SWITCH(G8, 1, “Bad”, 2, “Average”, 3, “Great”, “Unknown”)
You now have your correct rating description!
Let us try an unknown rating (40) and see the resulting description:
Bryan
Bryan Hong is an IT Software Developer for more than 10 years and has the following certifications: Microsoft Certified Professional Developer (MCPD): Web Developer, Microsoft Certified Technology Specialist (MCTS): Windows Applications, Microsoft Certified Systems Engineer (MCSE) and Microsoft Certified Systems Administrator (MCSA).
He is also an Amazon #1 bestselling author of 4 Microsoft Excel books and a teacher of Microsoft Excel & Office at the MyExecelOnline Academy Online Course.