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 Add ChatGPT to Microsoft Edge Sidebar

How to Add ChatGPT to Microsoft Edge Sidebar

To quickly use ChatGPT on Edge browser, you can add it to the right Sidebar of the browser for immediate use when needed.

AI-generated photos created in 2023 are causing a stir

AI-generated photos created in 2023 are causing a stir

In 2023, a series of AIs that create images with just a short description were released, including OpenAI's Dall-E, Stability.AI's Stable Diffusion, and Meta's Midjourney, Imagine with Meta AI.

How to access your Chromebooks clipboard manager

How to access your Chromebooks clipboard manager

The ability to copy and paste is a basic, simple function that any operating system has and must have.

How to take a screenshot on OnePlus phones

How to take a screenshot on OnePlus phones

OnePlus phones have three ways to take screenshots, including taking scrolling screenshots without additional software.

How to Use Start11 to Completely Overhaul Windows 11

How to Use Start11 to Completely Overhaul Windows 11

The tool used to customize Windows 11, Start11, offers a free trial and then charges a one-time fee of $9.99.

Instructions to fix Access Denied error when accessing files or folders on Windows

Instructions to fix Access Denied error when accessing files or folders on Windows

While having trouble accessing files and folders can be frustrating, don't panic—with a few simple tweaks, you can regain access to your system.

Top smartphones that emit the most dangerous radiation today

Top smartphones that emit the most dangerous radiation today

Stocklytics has released a list of the top smartphones with the highest radiation levels. Accordingly, Xiaomi and Samsung are the companies with the most smartphones with the highest radiation levels.

5 Best Google Sheets Add-ons to Make Data Analysis Easier

5 Best Google Sheets Add-ons to Make Data Analysis Easier

Google Sheets is a powerful tool for data analysis, but sometimes you need more power. There are plenty of add-ons that can speed up your spreadsheets and take your data processing to the next level.

The best way to scan and digitize old photos

The best way to scan and digitize old photos

Your precious old photos won't last forever. If you want to preserve your memories from time, damage, and dust, you need to bring them into the digital age.

Instructions to change Messenger color on phone, computer

Instructions to change Messenger color on phone, computer

Messenger has different chat themes for you to set for your chat. In addition to artistic chat themes or specific topics, you can also choose a color theme for Messenger.

How to play the Executioner lineup DTCL season 14

How to play the Executioner lineup DTCL season 14

The Executioner in season 14 stands out with his ability to deal powerful critical damage.

Latest X-Wukong Dai Chien Tam Gioi Code and how to redeem code

Latest X-Wukong Dai Chien Tam Gioi Code and how to redeem code

X-Wukong Dai Chien Tam Gioi gives players Gold, Linh Thach, Hon Ngoc... and many other attractive items through newbie giftcodes and event codes.

Latest Eternal Ember Code and How to Enter Code

Latest Eternal Ember Code and How to Enter Code

Eternal Ember Codes will give gamers currency and loot. Below are the Eternal Ember codes for you to enter and redeem, remember to follow this article for more code updates.

How to add a shared mailbox in Outlook

How to add a shared mailbox in Outlook

Shared mailboxes in Outlook make it easier for people to interact, view content, and share work together.

How to adjust the volume of each Chrome tab up to 600%

How to adjust the volume of each Chrome tab up to 600%

Volume Master is an extension installed on the Chrome browser that can adjust the volume of each separate tab on the browser, up to 600%.