How do I write a Case Statement in Google Sheets?

A Case Statement in Google Sheets is a function that allows you to evaluate a given value and return a result based on a set of specified conditions. It is written using the “switch” function, which takes three arguments: the value you want to evaluate, the condition you want to evaluate it with, and the value you want to return if the condition is true. You can also specify multiple conditions and return values. The syntax for the switch function is “=switch(value, condition, return_value, [additional conditions and return values])”.


A case statement is a type of statement that goes through conditions and returns a value when the first condition is met.

The easiest way to implement a case statement in Google Sheets is by using the SWITCH() function, which uses the following basic syntax:

=SWITCH(A2, "G", "Guard", "F", "Forward", "C", "Center", "None")

This particular function looks at cell A2 and returns the following value:

  • Guard” if cell A2 contains “G”
  • Forward” if cell A2 contains “F”
  • Center” if cell A2 contains “C”
  • None” if cell A2 does not contain any of the previous values

The following example shows how to use this function in practice in Google Sheets.

Example: Case Statement in Google Sheets

Suppose we have the following list of basketball positions:

We’ll use the following SWITCH() function to return a specific position name in column B based on the value in column A:

=SWITCH(A2, "G", "Guard", "F", "Forward", "C", "Center", "None")

We’ll type this formula into cell B2 and then copy and paste it down to every remaining cell in column B:

This formula returns the following values in column B:

  • Guard” if column A contains “G”
  • Forward” if column A contains “F”
  • Center” if column A contains “C”
  • None” if column A does not contain any of the previous values

Notice that the last value in column B returns a value of “None” since we didn’t specify a specific value to return for “Z” in the formula.

We could also use the following formula to simply return the original value from column A if it does not contain any of the specified values in the SWITCH formula:

=SWITCH(A2, "G", "Guard", "F", "Forward", "C", "Center", A2)

We’ll type this formula into cell B2 and then copy and paste it down to every remaining cell in column B:

Notice that the last value in column B simply returns a value of Z since the last value in column A didn’t contain any of the specified values in the SWITCH formula.

Note: You can find the complete documentation for the SWITCH function in Google Sheets .

x