Google Sheets SWITCH function
Compares a value with a list of cases and returns the matching one’s result. In Spanish Sheets it is called CAMBIAR.
Syntax
English Sheets
=SWITCH(expression, case1, value1, [default or case2, value2], …)
Spanish Sheets (Mexico locale)
=CAMBIAR(expresión, caso1, valor1, [predeterminado o caso2, valor2], …)
Spanish Sheets (Spain, Latin America)
=CAMBIAR(expresión; caso1; valor1; [predeterminado o caso2; valor2]; …)
| Argument | What it is |
|---|---|
| expression | The value to compare. |
| case1 | The first option. |
| value1 | What it returns on a match. |
| default or case2, value2optional | More pairs, or a last unpaired value as the default. |
Example
SWITCH(expression, case1, value1, case2, value2…, default) compares a value with a list of cases. It is ideal for turning codes into names.
=SWITCH(B2,"N","North","S","South","Central")
Common mistake
Without a default, an unknown code returns #N/A.
About Ads
This site uses Google AdSense to display ads. These ads help us keep WebHerramientas completely free. Ads are managed by Google and meet strict security and privacy standards.
Ads help us keep WebHerramientas free for everyone
Practice SWITCH
Type the formula in the sheet and check it instantly. Spanish or English function names both work. See all lessons
SWITCH
SWITCH(expression, case1, value1, case2, value2…, default) compares a value with a list of cases. It is ideal for turning codes into names.
In C2, translate the code: N is "North", S is "South" and anything else is "Central".
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Order | Code | Region | |
| 2 | P-01 | N | ||
| 3 | P-02 | S | ||
| 4 | P-03 | C | ||
| 5 | P-04 | N | ||
| 6 | P-05 | S | ||
| 7 |
Tip: while typing, click a cell or drag across several to insert their reference.
Frequently asked questions
- What is SWITCH called in Spanish?
- In Spanish Google Sheets it is CAMBIAR. The formula =SWITCH(B2,"N","North","S","South","Central") is written =CAMBIAR(B2;"N";"Norte";"S";"Sur";"Centro") (or with commas under a Mexico locale).
- Why does SWITCH use semicolons in some spreadsheets?
- It depends on each spreadsheet's locale, under File > Settings. Where the comma is the decimal mark (Spain, much of South America), arguments are separated by semicolons. Mexico and United States locales use commas.
- What is the most common SWITCH mistake?
- Without a default, an unknown code returns #N/A.