How to Use The Google Sheets SWITCH Function [Easy Guide]

by Sumitโ€ข

Apply the formula to the entire column

The Google Sheets SWITCH function is a helpful tool for changing how a cell behaves based on the value in another cell.

It’s incredibly useful in data interpretation and presentation.

To understand the SWITCH function, think of it as a function that can check multiple IF conditions. For example, you can check whether is a value is A or B or C, and based on what it is, you can return a corresponding value.

The benefit of using the SWITCH function is that it’s easier to read and understand, as compared with a nested IF function which can soon become quite complex as the number of conditions to check increases.

However, the SWITCH function has one significant limitation: the conditional case statements do not work with operators like โ€œless thanโ€ and โ€œgreater than.โ€ Therefore you need to keep in mind that SWITCH is only viable when youโ€™re working with exact matches.

The following processes break down the SWITCH function syntax and demonstrate how to use it in real-life situations.

Syntax of the Google Sheets SWITCH Function

The SWITCH function in Google Sheets has three main parts:

  • The Expression: This defines the values the function will test. This can be a cell reference such as “B2”
  • Cases: The google sheets case statement checks the value against the expression for an exact match. An example case is a numerical value: 0.
  • Values: If the expression and related case are an exact match, this is what the function returns in the cell. An example return value is a text โ€œNo.โ€

The Google Sheet SWITCH function syntax with two cases looks like this:

=SWITCH(expression, case1, value1, case2, value2)

Note that each attribute within the function is separated by a comma. When filled in with values, a SWITCH function will look something like this:

=SWITCH(B2,0,"No",1,"Yes")

In this example, the function interprets the contents of cell B2. If the cell value is 0, it returns โ€œNoโ€ while if the cell value is 1, it returns โ€œYes.โ€

Example 1 – Using the SWITCH Function With Two Conditions

Letโ€™s use a SWITCH function in Google Sheets real-world example.

The following dataset records the mailing list subscription status of 10 customers pulled from the server, but the server designates subscription status with a 0 for โ€œNoโ€ and a 1 for โ€œYes.โ€

Dataset for SWITCH function

While this dataset makes sense if you know what youโ€™re looking for, it wonโ€™t make sense to a person who is unfamiliar with how the server stores subscription status.

So weโ€™ll use a simple SWITCH function to make the data human-readable.

  1. Build your SWITCH function based on the topmost row. In the example, we are looking at row 2.
    • The expression is the cell weโ€™re looking to analyze. In the example, it is โ€œB2.โ€
    • Determine the case/value pairs. In this example, the first case/value pair is 0 and “No” while the second case/value pair is 1 and โ€œYes.โ€
    • Combine those values into the function. The example uses the following function:
      =SWITCH(B2,0,"No",1,"Yes").
  2. Insert the SWITCH function into the topmost cell in the return column. Using the SWITCH function
  3. Drag the bottom right square down the column to fill in the rest of the data. Draf the SWITCH function to the entire column

The example dataset makes more sense to human interpretation now thanks to the SWITCH function.

Example 2 – Using SWITCH function with One Condition and a Fallback (Default)

If you donโ€™t account for all possible Google Sheets case matches in a SWITCH function, it will return an error.

Fortunately, you can add the optional โ€œdefaultโ€ value (like a fall-back value) to the end of the statement to return a value when there isnโ€™t a matching case.

The SWITCH function with a single case and a default setting syntax looks like this:

=SWITCH(expression, case1, value1, default)

If weโ€™re using the SWITCH function to check the pass/fail status of students based on grades, we can configure it to return โ€œFailโ€ when it identifies an โ€œFโ€ case and โ€œPassโ€ for all other cases.

The function looks like this when filled out:

=SWITCH(B2,"F","Fail","Pass")

Our example data shows five students with different grades, we want to return either a โ€œPassโ€ or a โ€œFailโ€ value in the โ€œPass/Failโ€ column.

Student's data for SWITCH function

The following steps demonstrate how to apply a SWITCH statement with a default value.

  1. Build your SWITCH function based on the topmost row. In the example, we are looking at row 2.
    • The expression is the cell weโ€™re looking to analyze. In the example,it is โ€œB2.โ€
    • Determine the case/value pairs. In our example, we have a single case/value pair with a case of โ€œFโ€ and a value of โ€œFail.โ€
    • Determine the default return. In our example, itโ€™s โ€œPass.โ€
    • Combine those values into the function. The example uses the function:
      =SWITCH(B2,"F","Fail","Pass")
  2. Insert the SWITCH function into the topmost cell in the return column. SWITCH functiont to get pass fail
  3. Drag the bottom right square down the column to fill in the rest of the data. Apply the formula to the entire column

The SWITCH formula now fills column C with a โ€œFailโ€ for every โ€œFโ€ grade and a โ€œPassโ€ for every other grade under the default condition.

Example 3 – Using a Google Sheets SWITCH Statement with Two Conditions and a Fallback (Default)

Letโ€™s take one more look at using the SWITCH Google Sheets function with multiple case/value pairs and a default setting.

Our example data looks at the shift lengths of five employees on a given day.

We want to fill the โ€œShift Typeโ€ column with โ€œFullโ€ for a full eight-hour shift, โ€œOffโ€ for zero-hours designating no shift, and โ€œPartialโ€ for any other value.

Hours worked data for switch function

The following steps detail how to use a SWITCH function with all features enabled:

  1. Build your SWITCH function based on the topmost row. In the example, we are looking at row 2.
    • The expression is the cell weโ€™re looking to analyze. In the example, it is โ€œB2.โ€
    • Determine the case/value pairs. In our example, the first case/value pair is 8 and โ€œFullโ€ while the second case/value pair is 0 and โ€œNo.โ€
    • Determine the default return. In our example, itโ€™s โ€œPartial.โ€
    • Combine those values into the function. The example uses the function:
      =SWITCH(B2,8,"Full",0,"Off","Partial")
  2. Insert the SWITCH function into the topmost cell in the return column. Enter the SWITCH formula in the top most cell
  3. Drag the bottom right square down the column to fill in the rest of the data. Copy paste the formula to the entire column

The SWITCH function now populates the column with the conditional value responses.

Note: Google Sheets doesnโ€™t put a limit on how many case/value pairs you use in a SWITCH function. This tutorial uses only two cases at most for ease-of-explanation.

SWITCH Function vs IFS Function

Apart from the SWITCH function, there is another function that you can use as a substitute for the nested if formulas – the IFS function.

IFS function, as the name suggests, can accommodate multiple if conditions. It’s a relatively new function that makes nested if formulas are easier to read (just like the SWITCH function).

While the SWITCH function can be used when you want to compare an exact value with the expression, within the IFS function you can also use operators such as greater than or less than.

Personally, I prefer using the IFS formula as it can work with numbers as well as text values (including the cases where I need to compare using operators such as greater than or less than). The SWITCH function is more suited in conditions where you need to check for an exact match, which is most useful when your working with text data.

Google Sheets SWITCH Function FAQ

Is There a SWITCH Function in Google Sheets?

Yes, there is a SWITCH function in Google Sheets. It works similarly to the IF and IFS functions.

How Do You Switch Column A and B in Google Sheets?

You do not use the SWITCH function to switch columns. All you have to do is:

  1. Select the entire column you’d like to move by clicking the column header A for example
  2. Click, hold and drag it to the other side of the opposing column, B for example

This tutorial covered the foundation for using the Google Sheets SWITCH function.

I hope you found it useful!

Other Google Sheets tutorials you may find useful:

Access All

Free Templates

Enjoy our custom-made Google Sheets templates for free via email access