Learn the Google Sheets SWITCH Function [In 10 Minutes]

This guide will show you everything you need to know about the Google Sheets Switch function and when to use it instead of IF formulas.

What Is the Google Spreadsheet Switch Function

SWITCH in Google Sheets functions very similarly to a nested IF function. But, multiple IF formulae are combined to make a nested IF function, which can be confusing and slow down the spreadsheet’s performance. SWITCH has the benefit of having considerably easier syntax, which makes it simple for anybody to follow and monitor data inside a spreadsheet.

SWITCH analyses a logical phrase and checks it against one of the possible cases. The value specified in that case statement is then returned. When there are no matching cases, the default value is returned.

Google Sheets SWITCH Syntax

Before we examine how SWITCH in Google Sheets works, let’s examine its syntax. The syntax is:

=SWITCH(exp, case1, val1, [case2, val2], [default])

Now that we have taken an initial look at the syntax of the SWITCH formula let’s look at its parameters and their meaning.

  • exp: This parameter represents an expression, value, or reference to cells containing the expression or values. The function will test this expression to see if they are a match.
  • case1: This is the value with which the function will compare the exp parameter. This parameter is required for the function to work.
  • val1: This parameter defines the value which will be returned if the case1 parameter matches the exp parameter. This parameter is also required for the formula to work.
  • case2: Similar to the case1 parameter, this is the value which the function will compare the exp parameter with. This and other following case parameters are optional.
  • val2: Similar to the val1 parameter, This parameter defines the value which will be returned if the case2 parameter matches the exp parameter. This and other following val parameters are optional.
  • default: This optional parameter defines the last output, which will be returned if none of the defined cases match the expression.

How to Use Google Sheets Switch Statement

For this example, we have 1 to 5 corresponding to a grade. We also have the names of some students with their ratings beside them. We want to show their grades beside their names. In this case, we will be using the SWITCH function to do so.

Let’s take a look at the steps you need to follow to do this:

Starting off a Google Sheets SWITCH Function
  1. The first thing we need to do is write the starting part of the formula. This includes adding an Equal to (=) symbol, starting the formula.
  2. We need to add the keyword for the switch function and an opening bracket. The formula will look like =SWITCH(
A screenshot highlighting how to do a Google Sheets SWITCH function
  1. The first parameter we are going to add is the expression. In this case, it is cell B2 that contains the student’s rating.
  2. Now we need to add the case and val parameters. In our example, we have 5 cases, so we will need to add 10 parameters. Once you add them, the formula will be:=SWITCH(B2, J2, K2, J3, K3, J4, K4, J5, K5, J6, K6)
Adding absolute references to a SWITCH function in Google Sheets

As seen in the image, we have 10 students for whom we wish to add the grade. Doing this manually can be extremely tedious, and it leaves a margin for error. However, if you were to use Google’s suggested autofill feature, not only will the exp parameter shift forward, but the case and val parameters will also be shifted, resulting in an undesired output.

To fix this, we want to ensure that the case and val parameters do not change even if there is a change in the exp parameter. To do this, we are going to use absolute references. To do this, we will add a Dollar sign ($) beside the row and column constant. This means a cell reference like A1 will look like $A$1 when converted to an absolute reference.

When converting the formula in the example to be able to use the suggested autofill, the formula will be:

=SWITCH(B2, $J$2,$K$2,$J$3,$K$3,$J$4,$K$4,$J$5,$K$5,$J$6,$K$6)

A lot of the time, there may be data in your spreadsheet that may not match a defined case. In this case, you can specify a default parameter that will be displayed when there is no match found.

A screenshot showing what it looks like when you use the Default parameter in a SWITCH Google Sheets formula

The default parameter is added as the last parameter in the formula. It should be enclosed in quotation marks. In this example, we added a parameter that shows an “Invalid Rating” message if none of the expressions match the specified case.

Differences in IFS, IF, and SWITCH Formula

Although the three functions may seem similar at first, there are a few key differences that can make one function better than the other.

SWITCH Explanation

When using the SWITCH function, the function will return the corresponding value of the case. In the example above, the function matched the student’s rating to the rating given in the grade key. After comparing, the grade was displayed when it matched the student’s rating.

If the test cannot find a matching case, the function can return a default value. This value is optional and can be added as the last parameter in quotation marks. For the above example, this option showed an “Invalid Rating” message. The formula will display a #N/A error if no parameter is added.

IFS Explanation

When you use the IFS function, it works similarly to SWITCH and evaluates several conditions. Then, it returns a value for the first case that returns as true.

However, it deviates from the SWITCH function as the IFS function can not immediately return a value if there is no match. This can be done using a workaround, but this can be tedious for many users.

IF Explanation

The IF function is very similar to IFS as it returns a value if an expression is true and another output if the logical expression returns s false. However, IF can only have two outputs, either true or false. You must nest the function if you wish to check multiple criteria.

Frequently Asked Questions

Does Google Sheets Have a SWITCH Function?

Yes, it does have a SWITCH function that operates under the following syntax:

=SWITCH(exp, case1, val1, [case2, val2], [default])

What Does the Google Sheets Switch Function Do?

To modify a cell’s behavior based on a value in another cell, use the Google Sheets SWITCH function. It is tremendously helpful in the display and comprehension of data. Consider the SWITCH function as a function that may examine several IF conditions to comprehend how it works.

What Is the Syntax for SWITCH Google Sheets?

The syntax for SWITCH is =SWITCH(exp, case1, val1, [case2, val2], [default]). The formula requires at least three parameters to work.

The exp parameter represents an expression, value, or reference to cells containing the expression or values that may return a value.

The case parameter is the function’s value to compare the exp parameter.

The val parameter defines the value returned if the case parameter matches the exp parameter. The default parameter is an optional parameter that defines the last parameter, which will be returned if none of the defined cases match the expression.

Should I Use IF, IFS or SWITCH?

Use IF if you want to evaluate your data logically. While the IF function functions similarly to SWITCH, you can use it with logical expressions like greater or smaller. However, SWITCH might be a useful alternative if you’re searching for exact matches to criteria in your dataset to avoid utilizing several lengthy and intricate nested IF functions. The IF function is much better for finding values if it contains partial matches with the use of wildcards.

When Shouldn’t You Use Switch in Sheets?

There are a few circumstances in Google Sheets where you shouldn’t utilize SWITCH. For example, if you want to compare a number to a list of text values. Instead, you may utilize the IF function. If there are more than two criteria to compare, SWITCH should also be avoided. The IFERROR function can be used to compare all conditions at once.

Wrapping Up the Google Sheets Switch Function Guide

This guide covered what the SWITCH function does and when you should use it. There are plenty of applications for this powerful function, but don’t forget that sometimes using IF or IFS may be better. Let us know in the comments if you need any more info.

Most Popular Posts

Jake Wright

Jake Wright

Jake is a spreadsheet expert and content writer from New Zealand. He has a double Bachelor's Degree in Teaching and has been working in the education industry for over 11 years. His experience makes him adept at breaking down complex topics so that everyone is able to understand.