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

Top 5 best automatic home coffee makers

Top 5 best automatic home coffee makers

The automatic home coffee maker is a modern and professional product, bringing you and your family delicious cups of coffee with just a few quick steps.

Difference between regular TV and Smart TV

Difference between regular TV and Smart TV

Smart TVs have really taken the world by storm. With so many great features and the ability to connect to the Internet, technology has changed the way we watch TV.

Why doesnt the freezer have a light but the refrigerator does?

Why doesnt the freezer have a light but the refrigerator does?

Refrigerators are familiar appliances in families. Refrigerators usually have 2 compartments, the cool compartment is spacious and has a light that automatically turns on every time the user opens it, while the freezer compartment is narrow and has no light.

2 Ways to Fix Network Congestion That Slows Down Wi-Fi

2 Ways to Fix Network Congestion That Slows Down Wi-Fi

Wi-Fi networks are affected by many factors beyond routers, bandwidth, and interference, but there are some smart ways to boost your network.

How to Downgrade from iOS 17 to iOS 16 without Losing Data using Tenorshare Reiboot

How to Downgrade from iOS 17 to iOS 16 without Losing Data using Tenorshare Reiboot

If you want to go back to stable iOS 16 on your phone, here is the basic guide to uninstall iOS 17 and downgrade from iOS 17 to 16.

What happens to the body when you eat yogurt every day?

What happens to the body when you eat yogurt every day?

Yogurt is a great food. Is it good to eat yogurt every day? What will happen to your body when you eat yogurt every day? Let's find out together!

Which type of rice is best for health?

Which type of rice is best for health?

This article discusses the most nutritious types of rice and how to maximize the health benefits of whichever rice you choose.

How to wake up on time in the morning

How to wake up on time in the morning

Establishing a sleep schedule and bedtime routine, changing your alarm clock, and adjusting your diet are some of the measures that can help you sleep better and wake up on time in the morning.

Rent Please! Landlord Sim Tips for Beginners

Rent Please! Landlord Sim Tips for Beginners

Rent Please! Landlord Sim is a simulation mobile game on iOS and Android. You will play as a landlord of an apartment complex and start renting out an apartment with the goal of upgrading the interior of your apartments and getting them ready for rent.

Latest Bathroom Tower Defense Codes and How to Enter Codes

Latest Bathroom Tower Defense Codes and How to Enter Codes

Get Bathroom Tower Defense Roblox game codes and redeem them for exciting rewards. They will help you upgrade or unlock towers with higher damage.

Structure, symbols and operating principles of transformers

Structure, symbols and operating principles of transformers

Let's learn about the structure, symbols and operating principles of transformers in the most accurate way.

4 Ways AI Is Making Smart TVs Better

4 Ways AI Is Making Smart TVs Better

From better picture and sound quality to voice control and more, these AI-powered features are making smart TVs so much better!

Why ChatGPT is better than DeepSeek

Why ChatGPT is better than DeepSeek

DeepSeek initially had high hopes. As an AI chatbot marketed as a strong competitor to ChatGPT, it promised intelligent conversational capabilities and experiences.

Meet Fireflies.ai: The Free AI Secretary That Saves You Hours of Work

Meet Fireflies.ai: The Free AI Secretary That Saves You Hours of Work

It's easy to miss important details when you're jotting down other essentials, and trying to take notes while chatting can be distracting. Fireflies.ai is the solution.

How to raise Axolotl Minecraft, tame Minecraft Salamander

How to raise Axolotl Minecraft, tame Minecraft Salamander

Axolot Minecraft will be a great assistant for players when operating underwater if they know how to use them.