SWITCH function in Google Sheets
Tests an expression against a list of cases and returns the corresponding value of the first matching case, with an optional default value if nothing else is met.
=SWITCH(expression, case1, value1, [case2, value2, ...], [default])SWITCH syntax and parameters
Six arguments, three required.
- expressionanyRequired
Any valid values.
- case1anyRequired
The first case to be checked against expression.
- value1anyRequired
The corresponding value to be returned if case1 matches expression.
- case2anyOptional
- value2anyRepeating
- defaultanyOptional
Optional: An optional value, specified as the last parameter, to be returned if none of the cases match the expression.
SWITCH examples
Formulas you'll actually reuse.
Commission rate by region, with a default for everything else:
=SWITCH(A2, "West", 0.08, "North", 0.07, "South", 0.06, 0.05)Result
0.08Weekend or weekday from a date — several cases, one fallback:
=SWITCH(WEEKDAY(E2, 2), 6, "Weekend", 7, "Weekend", "Weekday")Result
"Weekday"
SWITCH in Excel
Same name — your formula ports as-is.
Try SWITCH in the playground
Edit the example — nothing to install.
Preloaded with the SWITCH formula from Example 1 — change anything and watch it respond.
SWITCH errors
What they mean — and the fixes.
#N/ANo case matched and no default was given — add a final unpaired argument as the fallback.
Related functions
More ways Google Sheets gets this done.
- ANDReturns true if all of the provided arguments are logically true, and false if any of the provided arguments are logically false.LogicalExcel
- FALSEReturns the logical value `FALSE`.LogicalExcel
- IFReturns one value if a logical expression is `TRUE` and another if it is `FALSE`.LogicalExcel
- IFERRORReturns the first argument if it is not an error value, otherwise returns the second argument if present, or a blank if the second argument is absent.LogicalExcel
- IFNAEvaluates a value. If the value is an #N/A error, returns the specified value. .LogicalExcel
- IFSEvaluates multiple conditions and returns a value that corresponds to the first true condition.LogicalExcel