EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Certification Courses
  • 120+ Courses All in One Bundle
  • Login
Home Excel Excel Resources Excel Functions Excel SWITCH Function
Secondary Sidebar
Excel Functions
  • Excel Functions
    • Excel Column Total
    • VLOOKUP to Return Multiple Values
    • User Defined Function in Excel
    • Excel SWITCH Function
    • Excel FV Formula
    • Excel AVERAGEIF
    • Simple Formula in Excel
    • Excel Scatter Chart
    • Excel Bar Chart
    • LINEST Excel Function
    • RANK Excel Function
    • Excel MOD Function
  • Excel Tools (114+)
  • Financial Functions in Excel (17+)
  • Logical Functions in Excel (14+)
  • Lookup and Reference Functions in Excel (36+)
  • Maths Function in Excel (47+)
  • TEXT and String Functions in Excel (26+)
  • Date and Time Function in Excel (24+)
  • Statistical Functions in Excel (59+)
  • Information Functions in Excel (4+)
  • Excel Charts (56+)
  • Excel Tips (220+)
  • Workplace Productivity (4+)
  • Microsoft Office Tools (15+)
  • Excel Formula and Functions (22+)
  • MS Excel Shortcuts (4+)
Excel Functions Courses
  • EXCEL ADVANCED Certification Course
  • EXCEL Certification COURSE

Excel SWITCH Function

By Jeevan A YJeevan A Y

SWITCH Function example

Excel SWITCH Function (Table of Contents)

  • SWITCH Function in Excel
  • How to use the SWITCH Function in Excel?

SWITCH Function in Excel

The switch function in Excel is used to compare one value with the values of another list and returns the first matched value if found. This function also considers and allows the user to enter the optional default value if there is no match found. In other words, the Switch function matches the multiple values but returns only the first value out of the selected range. This is quite useful when we have duplicate values, and out of those, we want only the first value to be returned.

Start Your Free Excel Course

Excel functions, formula, charts, formatting creating excel dashboard & others

Syntax:

The Syntax of the SWITCH function includes 4 parameters. Out of 4 parameters of SWITCH functions, 3 are mandatory, and the fourth one is optional based on our requirement.

SWITCH Function example 1-1

  • Expression: This is simply the value or cell we are trying to test the logic.
  • Value1: This the test value or logical value comparing to the Expression. We can give 126 logical tests.
  • Result1: If the first logical test is true, what should be the result we want.
  • Default or Value 2: Here, we can see two things. One is Default; if the first logical test is FALSE, what is the default value we want. The second one is Value2; this is the second logical test for the Expression.
  • Result 2: This is the result of the second logical test we are testing.

How to Use SWITCH Function in Excel?

Using the SWITCH Function in Excel is very easy. Let’s understand the Function in Excel by some examples given below.

You can download this SWITCH Function Excel Template here – SWITCH Function Excel Template

SWITCH Function in Excel – Example #1

As I said at the beginning, SWITCH is an alternative to the IF condition in excel. We will now see how the simple IF condition works and compare the SWITCH with the IF condition in excel.

I have a few fruit names here. I have 4 fruit names from cell A2 to A5 in excel.

SWITCH Function example 1-2

Each fruit has its own status here; the status is based on how they impact human body temperature. Let me apply the IF condition to test the results. The formula for this method is :

=IF (A2=”Apple”, “Medium”, IF(A2=”orange”, “Cold”, IF(A2=”Sapota”, “Heat”, IF(A2=”Watermelon”, “Cold”, “???”))))

IF function tests if the value in the cell A2 is equal to Apple, then the result should be Medium. If the result is false, then again one more IF condition will test if the value in the cell A2 is equal to Orange, the result should be Cold; if the result is again false, then one more IF condition will tests if the value in the cell A2 is equal to Sapota then the value will be Heat and so on. Finally, if none of the conditions is TRUE, then it will return the result as ???

Result

Like this IF condition tests multiple criteria’s and gives the result based on the logical tests. In the above example, we have applied totally 4 different IF conditions to get the result; this why we call it a nested IF condition.

However, the SWITCH function can replace those many IF conditions and can give the result in one single formula.

The formula for SWITCH Function is:

=SWITCH (A2, “Apple”, “Medium”, “Orange”, “Cold”, “Sapota”, “Heat”, “Watermelon”, “Cold”, “???”)

Formula for SWITCH Fuction

Now, look at the above results from the SWITCH function; it is exactly the same as the IF condition. Let me break down the formula into pieces for better understanding.

=SWITCH(A2, “Apple”, “Medium”, : This is the first argument of the function. If the cell A2 value is equal to Apple, then it will get the result as Medium.

“Orange”, “Cold”, : Unlike the IF condition, we need not to again put one more SWITCH condition here; instead, we can go on in the formula. Again, we need to mention the expression here (A2 cell) rather than simply enter the condition straight away. The condition is If the cell A2 value is equal to Orange, then the result should be Cold.

“Sapota”, “Heat”,: Similarly, if the cell A2 value is equal to Sapota, then the result should be Heat.

“Watermelon”, “Cold”, : If the cell A2 value is equal to Watermelon, then the result should be Cold.

“???”) : This is the final part of the formula. If none of the above 4 conditions is satisfied, then the result will be ???

Like this, the SWITCH function can be used as an alternative to nested IF conditions. But the SWITCH function has its own limitation, too; we will see that limitation in the below section.

SWITCH Function in Excel – Example #2

The problem with the SWITCH function is limited to exact matching only. It cannot use any kind of operators in the formulas. Some of the common operators are >=(greater than or equal to), <=(less than or equal to) etc..

Take a look at the example now. Typical examination example, I have scores and criteria.

I will apply the IF formula to determine the results.

For this, apply the formula given below:

=IF(A2>=85, “Distinction”, IF(A2>=75, “First Class”, IF(A2>=60, “Second Class”, IF(A2>=35, “Pass”, “Fail”))))

Formula Applied

But SWITCH function cannot accept operator symbols to determine the result, and still, we have to rely on nested IF conditions to get the results.

Result

Things to Remember

  • SWITCH Function in Excel works only for exact matching.
  • In the case of the operator, a symbol to determine the logic, we have to rely on IF conditions.
  • SWITCH Function in Excel can handle 126 logical tests and results, but IF is limited to 64 conditions.
  • It is recommended to use the SWITCH Function in exact match scenarios or use nested IF conditions.

Recommended Articles

This has been a guide to SWITCH Function in excel. Here we discuss how to use the SWITCH Function in excel and its limitations, along with practical examples and a downloadable excel template. You can also go through our other suggested articles–

  1. IFERROR Function in Excel
  2. Switching Columns in Excel
  3. Logical Functions in Excel
  4. VBA Switch
Popular Course in this category
Excel Advanced Training (16 Courses, 23+ Projects)
  16 Online Courses |  23 Hands-on Projects |  140+ Hours |  Verifiable Certificate of Completion
4.8
Price

View Course

Related Courses

Excel Training (23 Courses, 9+ Projects)4.9
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Excel Charts
  • Excel Tips
  • All Tutorials
Certification Courses
  • All Courses
  • Excel VBA Course - All in One Bundle
  • VBA Course
  • Excel Data Analysis Course
  • Excel for Marketing Course
  • Excel for Finance Course
  • Excel for HR Training

ISO 10004:2018 & ISO 9001:2015 Certified

© 2023 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

Download SWITCH Function Excel Template

EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

Download SWITCH Function Excel Template

EDUCBA

डाउनलोड SWITCH Function Excel Template

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more