SWITCH Function – Google Sheet

How to test multiple cases without using IF Function in Google Sheet?

The SWITCH function is a useful tool for categorizing data. In the right circumstances, it can save you from messy, nested IF statements.

The SWITCH function is used to test an expression against a list of cases. It returns a value when the expression is EQUAL to one of the cases. 

It has some similarities to the IFS function, but differs because SWITCH tests for exact matching rather than whether a condition is true (e.g. X > Y). SWITCH also has a default option to return a value if no match is found.

Let’s see an example. Suppose we have this data set of student grades and we want to add context to each grade level.

how to use SWITCH Function in Google Sheet?

Use this SWITCH function to categorize these grades:

  “A”,”Top marks! Great job!”,
  “B”,”Keep up the good work”,
  “C”,”Could do better”,
  “Failed. Remidial study needed”

Let’s break it down:

B2 is the condition we’re going to test. It’s the grade letter from column B and it’s the input to our SWITCH function.

We check the value of B2 against the first case “A”. If they match (i.e. the grade in B2 was also “A”) then SWITCH returns the string “Top marks! Great job!”.

If the value from B2 doesn’t match “A”, we move on and test it against “B”  and if that fails, test against “C”.

If the condition doesn’t match any of the cases, the last string is returned: “Failed. Remedial study needed”. It’s our catch-all solution. Anything that’s not “A”, “B” and “C” will return this answer.

This is what the solution looks like:

how to use SWITCH Function in Google Sheet?

Give it a try and SWITCH things up!

Your Can Master Complete Excel in Less Than 2 Coffees $. Most Recommended Course

Leave a Comment