Logical

Switch

Compares one value against a list of matches and returns the result for the first match.

Syntax

Switch(Formula, Match1, Result1 [, Match2, Result2, ...] [, DefaultResult])

Parameters

Formula
The value to compare.
Match
A value to test for equality.
Result
Returned when its match is equal to Formula.
DefaultResultoptional
Returned when nothing matches.

Examples

  1. =Switch(StatusCode, 200, "OK", 404, "Not found", "Error")

    A label for an HTTP status code

Maker notes

  • Cleaner than nested If calls when every branch tests the same value.
Official documentation on Microsoft Learn

↑ ↓ moveEnter open