How to use the SWITCH function in Excel 2016

The SWITCH function in Excel allows you to perform multiple checks on a value and return results based on conditions. Here are the details on how to use the SWITCH function in Excel .

If you have spent too much time creating a nested IF formula ( IFS function ), you will love using the new SWITCH function in Excel . This function saves you time in situations where you need to use the IFS function. Previously, this function was only available in VBA, but SWITCH was recently added to Excel 2016, Excel Online and Mobile, Excel for computers and Android phones. This article will guide you through how to use the SWITCH function in Excel 2016.

SWITCH function syntax

The SWITCH function compares an expression to a list of values ​​and returns the first matching value. If no match is found, it may return a default value.

The structure of the 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 is a required argument used to compare value1… value 126.
  • ValueN is a value used to compare against the expression.
  • 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 does not have a corresponding resultN expression and must be the last argument in the function.

Since functions are limited to 254 arguments, you can use up to 126 pairs of value and result arguments.

How to use the SWITCH function with other Excel functions

You can also combine the SWITCH function with other Excel functions. For example, you can nest it inside the IF function to increase overall efficiency and create more complex formulas.

Additionally, you can combine SWITCH with the following Excel functions:

  • SUM function : You can sum values ​​based on specific conditions using the SUM and SWITCH functions. For example, use the SWITCH function first to determine the values ​​to sum based on the conditions, and then use the SUM function to calculate.
  • INDEX And ​​MATCH Functions : Using these functions, you can extract data from a table based on certain conditions. For example, you can use the SWITCH function to determine target values, and then use INDEX and MATCH to extract the required data. You can also use the VLOOKUP function to get the corresponding values.

Compare the SWITCH function with the IFS function

The SWITCH function, like the IFS function, helps define a series of conditions. However, with the SWITCH function, you can define an expression and a series of values ​​and results, not a number of conditional statements. With the SWITCH function, you do not need to repeat the expressions again and again as in the IFS function.

For example, the IFS function below finds the exact states.

How to use the SWITCH function in Excel 2016

Explanation: Cell A2 contains the string 85-UT. The RIGHT function extracts the rightmost 2 characters from this string (UT). As a result, the IFS function returns the correct state (Utah). If the rightmost 2 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 more readable.

How to use the SWITCH function in Excel 2016

Explanation: if the first argument (RIGHT(A2,2) in this example) equals UT, the SWITCH function returns Uta; if TX returns Texas; if OH returns Ohio. The last argument (the question mark in this example) is always the default value (if there is no match).

Similarly, you can see the example below with the ranking system, the SWITCH function looks more compact.

How to use the SWITCH function in Excel 2016

How to use the SWITCH function in Excel 2016

Let's see how the SWITCH function works in combination with other functions. Let's say we have a number of dates and want to quickly see if it's today, yesterday, or tomorrow. To do this, we'll use the TODAY function which returns the serial number of the current date and the DAYS function which returns the number of days between two dates.

You can see the SWITCH function works perfectly for this task.

How to use the SWITCH function in Excel 2016

With the IF function, the conversion requires some nesting and complexity. So you will be more prone to errors.

How to use the SWITCH function in Excel 2016

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.

How to use the SWITCH function in Excel 2016

Explanation: since the symbols "<=" and="" "="">" are used here in this IFS function, you cannot use the SWITCH function.

The SWITCH function is really a useful function, it saves time and makes less mistakes.

Good luck!

See also:

Sign up and earn $1000 a day ⋙

Leave a Comment

How to fix sound problems on Xbox

How to fix sound problems on Xbox

It can be difficult to troubleshoot sound issues on Xbox when the problem can occur anywhere between your TV setup and your Xbox system settings.

Answer to the question: Being a professional soccer player in Lien Quan

Answer to the question: Being a professional soccer player in Lien Quan

Being a professional soccer player is one of the suggestions in the Grass Professor event of Lien Quan Mobile. Let's explore with Quantrimang to see who the character this event wants to mention is.

18 mysterious and strange places appearing on Google Earth that make people surprised

18 mysterious and strange places appearing on Google Earth that make people surprised

The vast Earth has many mysterious lands that humans have not known and have not set foot on. Nowadays, thanks to the Google Earth tool, anyone can search and explore strange and mysterious places on this planet.

14 Best New AI Features Adobe Revealed at Adobe Max 2024

14 Best New AI Features Adobe Revealed at Adobe Max 2024

Adobe Max 2024 has launched a series of exciting updates, introducing powerful new AI tools to Adobe's toolset.

Why do cats cover their faces when they sleep?

Why do cats cover their faces when they sleep?

There are many different explanations for why cats cover their faces while sleeping, from trying to keep warm to protecting their whiskers. Here's the answer to the question of why cats cover their faces while sleeping.

Quiz: How many meters is 1 foot?

Quiz: How many meters is 1 foot?

How many meters is 1 foot? If you don't know, let's find the answer together!

How many kilometers is a light year, how many earth years?

How many kilometers is a light year, how many earth years?

How many kilometers are 120 light years? How many kilometers are 40 light years? Let's find out together about a light year to find the answer!

Best time to post Instagram Reels

Best time to post Instagram Reels

The timing of your Instagram Reels can make the difference between massive engagement and dead silence. Let’s find out the best times to post on Instagram Reels.

Status about dogs, funny and humorous captions about pets

Status about dogs, funny and humorous captions about pets

There are many funny captions about dogs on the Internet. This article will gather for you the funniest, most humorous, and most interesting poems about dogs.

How to change NAT type on Windows 11/10

How to change NAT type on Windows 11/10

You will have the best gaming experience if you use Open NAT or at least Moderate NAT. That is why you need to learn how to change the NAT type.

8 Features Apple Notes Is Still Missing

8 Features Apple Notes Is Still Missing

After several updates, Apple Notes still lacks some features that could make the app even better.

4 Practical Uses of Password Managers You Didnt Know About

4 Practical Uses of Password Managers You Didnt Know About

You probably know that password managers are great for storing your online logins. But did you know they have many other great uses?

What do the heart colors on Messenger mean?

What do the heart colors on Messenger mean?

With the Messenger heart icon, you can choose different colors to use for different situations to express what you want to say to the other person.

How to Message Meta AI in WhatsApp Groups

How to Message Meta AI in WhatsApp Groups

Not only can you use Meta AI with individual WhatsApp messages, you can now send Meta AI messages in WhatsApp groups.

NVIDIA CEO: AI will replace humans in specific jobs with 1000 times higher productivity

NVIDIA CEO: AI will replace humans in specific jobs with 1000 times higher productivity

The concept of artificial intelligence - AI is becoming more and more popular, which means that this superior technology is gradually being effectively deployed in many fields as well as in all aspects of modern life.