Get help

Help center

Guides and answers

Contact support

Write to our team

Sign in to

Workflows

Build processes with your team

Automations

Connect files and automate tasks

One system, four parts

AI agents

Virtual Employees that work 24/7

Automations

Connect files and automate tasks

Workflows

Build processes with your team

Data Space

Trusted data sharing and control

Solutions by department

Finance

Reports, budgets, and reconciliations

Inventory and manufacturing

Stock, orders, and production in one view

HR

Timesheets, attendance, and reviews

Project management

Status and workload across projects

Sales and CRM

Leads and deals kept up to date

Education

Student records and school data

Finance

Turn manual finance work into reports that update themselves.

What Finance teams automate

  • Track payables and receivables
  • Build cash flow statements
  • Compare budget against actuals

Inventory and manufacturing

See stock levels and automate ordering.

What inventory and manufacturing teams automate

  • Track inventory across multiple sites
  • Connect sales, purchasing, and warehouse data
  • Link a barcode scanner to your sheet

HR

Run recruitment, attendance, and OKR tracking from your sheets.

What HR teams automate

  • Track recruitment and onboarding
  • Record team OKRs and results
  • Track check-ins, check-outs, and leave

Project management

Assign tasks and track hours without manual updates.

What project teams automate

  • Assign tasks and track status changes
  • Estimate effort and log hours worked
  • Track milestones across projects

Sales and CRM

Track leads and sales performance with automated reports.

What sales teams automate

  • Track and convert leads
  • Set sales goals and track team metrics
  • Monitor sales KPIs on dashboards

Education

Automate attendance, grades, and school purchasing.

What schools automate

  • Track attendance and notify parents
  • Record and compare class grades
  • Track inventory lent to students and staff

Find a use case

By department

How each team uses Sheetgo

By industry

How each industry uses Sheetgo

By company size

Small, medium-sized, or large

Learn

Blog

Guides and product news

Customer stories

How teams like yours use Sheetgo

Help center

Guides and answers

Why Sheetgo

Compare

How Sheetgo compares with other tools

Security

How we protect your data

Trust center

Our compliance details

Sign in to

Workflows

Build processes with your team

Automations

Connect files and automate tasks

One system, four parts

AI agents

Virtual Employees that work 24/7

Automations

Connect files and automate tasks

Workflows

Build processes with your team

Data Space

Trusted data sharing and control

Solutions by department

Finance

Reports, budgets, and reconciliations

Inventory and manufacturing

Stock, orders, and production in one view

HR

Timesheets, attendance, and reviews

Project management

Status and workload across projects

Sales and CRM

Leads and deals kept up to date

Education

Student records and school data

Find a use case

By department

How each team uses Sheetgo

By industry

How each industry uses Sheetgo

By company size

Small, medium-sized, or large

Get started

Templates

Ready-made workflows to start from

Learn

Blog

Guides and product news

Customer stories

How teams like yours use Sheetgo

Help center

Guides and answers

Why Sheetgo

Compare

How Sheetgo compares with other tools

Security

How we protect your data

Trust center

Our compliance details

Help center

Guides and answers

Contact support

Write to our team

Workflows

Build processes with your team

Automations

Connect files and automate tasks

How to use the SWITCH function in Google Sheets

This Google Sheets SWITCH evaluates an expression against a set of specific cases. The first case to evaluate as TRUE will return a corresponding value. If all cases are FALSE, the formula can return a default value.

The function works similarly to nested IF functions. But its syntax is much simpler, making it easy for anyone to read formulas in a spreadsheet. 

It’s difficult to fully grasp this function without seeing some examples. But it’s worth the investment to learn how to use it.

Syntax

=SWITCH(logical_expression, case1, value1, [case2, value2]…, default)

  • logical_expression– the expression to evaluate as TRUE or FALSE. This is what the function will test against each case.
  • case1 – the first case to evaluate against the logical_expression.
  • value1 – the value the function returns if case1 is TRUE.
  • case2 – the second case to evaluate against the logical_expression.
  • value2 –the value the function returns if case2 is TRUE.
  • default– the value to return if all the cases are FALSE.

The logic behind this function is illustrated in the flowchart below.

switch-function-google-sheets-1

How to use the SWITCH function

Example 1: Basic use

Let’s start with the standard version of the function, and take a look at how it works.

=SWITCH(A2, 1, "Alex", 2, "Bob", 3, "Charlie", "None")

SWITCH FORMULA GOOGLE SHEETS 1

In this example, the expression is just ‘2’. It is compared with all three cases, and it matches the second case so the function returns the text ‘Bob’.

Example 2: Setting a default value

Let’s see what happens when none of the cases match the expression.

SWITCH FORMULA GOOGLE SHEETS 2

The expression ‘5’ is FALSE for all three cases, and as a result the function returns the default value ‘None’.

If you don’t define a default value the SWITCH function produces an error, as shown below.

SWITCH FORMULA GOOGLE SHEETS 3

Example 3: Matching weekdays with colors

Say I’ve planned out my wardrobe for the week, with a different color for every weekday.

Column D has various weekdays and in column E SWITCH matches the day of the week with the correct color.

=SWITCH(C2, A2, B2, A3, B3, A4, B4, A5, B5, A6, B6, "Not a valid weekday")

SWITCH FORMULA GOOGLE SHEETS 4

The function here is long, but you can easily break it down into three parts:

  1. The “What day is it?” column, basically what the function is looking for.
  2. After this, there are a series of case and value combinations. Each one declares that if the reference cell matches a weekday, then the function should output the corresponding color.
  3. Finally, there is a default value (“Not a valid weekday”) if none of the cases match the logical expression.

Should I use SWITCH or IF function?

The following example illustrates the benefits of the SWITCH function when compared to the IF function. It adapts the formula to use IF instead of SWITCH.

The formula is noticeably more complicated.

=IF(C2 = A2, B2, IF(C2 = A3, B3, IF(C2 = A4, B4, IF(C2 = A5, B5, IF(C2 = A6, B6, "Not a valid weekday")))))

SWITCH FORMULA GOOGLE SHEETS 5

Use IF to perform logical tests on your data. As this function can be used with logical expressions such as “smaller than” or “greater than”. 

Use SWITCH to work with exact matches within a dataset, as it will help avoid complex nested IF statements

Combining SWITCH with other functions

Using SWITCH with MONTH

Some date functions like MONTH return numbers that may be hard to interpret. You can use SWITCH to return more meaningful messages.

To replace the month numbers returned by MONTH you can set a case for each of the 12 potential results.

=SWITCH(MONTH(C21), 1, "JAN", 2, "FEB", 3, "MAR", 4, "APR", 5, "MAY", 6, "JUN", 7, "JUL", 8, "AUG", 9, "SEP", 10, "OCT", 11, "NOV", 12, "DEC", "No match")

Using SWITCH with WEEKDAY

Similarly to MONTH, the output of WEEKDAY is difficult to read. Not only does it output numbers instead of text, the numbers can be set to correspond to different days.

This is the basic formula to use if Sunday is considered the first day of the week.

=SWITCH(WEEKDAY(C21, 1), 1, "SUN", 2, "MON", 3, "TUE", 4, "WED", 5, "THU", 6, "FRI", 7, "SAT", "No match")

Combining SWITCH with ERROR.TYPE

Another formula that returns cryptic codes is ERROR.TYPE, and SWITCH can replace them with more meaningful messages.

The formula below is just a starting point. It would be a good idea to adapt it to provide hints on how to fix these errors on your spreadsheet.

=IF(ISERROR(C21), SWITCH(ERROR.TYPE(C21), 1, "Null error", 2, "Division by zero error", 3, "Value error", 4, "Reference error", 5, "Name error", 6, "Number error", 7, "Not available error", 8, "Getting data error", 9, "Spill error", 10, "Calc error", "Unknown error"), "No error")

Handle your data with Sheetgo

SWITCH is a great function, but it can only be used in a handful of cases. Sheetgo provides an arsenal of data processing tools to automate your workflows. 

This platform has the potential to revolutionize your work, automating tedious tasks and sharing insights across your team.

These are just some of the key Sheetgo features:

  • Automations – Link your data sources and schedule transfers to have your information available when you need it.
  • Data processors – Query, merge and split data to suit your needs. Transfer data and keep its formatting.
  • Sheetgo Forms – Create forms in seconds to conduct surveys and retrieve valuable information.

Try out Sheetgo today and start saving precious time.

SWITCH it up!

The SWITCH function in Google Sheets is an alternative to nested IF statements.

By evaluating an expression against a series of cases and returning the corresponding value for the first true case, it simplifies complex logical tests and makes your formulas easier to understand

Editor’s note: This is a revised version of a previous post that has been updated for accuracy and comprehensiveness.

You may also like…

google sheets features and formulas

How to find nominal interest rate using Google Sheets

Sarah is a young professional making significant financial decisions. From credit cards to mortgages, student loans, and investment...
google sheets features and formulas

Pull Google Calendar data into Google Sheets using Apps Script

This post was originally published in our community forum. Objective : This guide demonstrates how to use Google Apps Script to pull data...
google sheets features and formulas

Using the PROPER function to capitalize the first letter of each word in Google Sheets

Note: This post was originally published in our community forum. Ever found yourself needing to clean up a list of names, titles, or any...