Skip to main content

SWITCH

The SWITCH function compares an expression against a list of values and returns the result corresponding to the first matching value.

Syntax

=SWITCH(expression, value1, result1, [value2, result2], ..., [default])

Parameters

  • expression: The value to compare against value1, value2, etc.
  • value1, result1: The first value to compare against and its result if matched
  • value2, result2, ...: Optional. Additional value-result pairs
  • default: Optional. The value to return if no match is found

Examples

=SWITCH(2, 1, "One", 2, "Two", 3, "Three") // Returns "Two"
=SWITCH("B", "A", "First", "B", "Second", "Unknown") // Returns "Second"
=SWITCH(4, 1, "One", 2, "Two", "Other") // Returns "Other"