SWITCH() : choose a value based on multiple cases (alternative to nested IFs)
Updated on
The SWITCH function compares an expression to multiple cases and returns the first matching value, as text. It is useful when several conditions need to be tested in a single formula, and can replace sequences of nested IF()s.
The output format of the result can be configured in the output field options of the formula editor. For more details, see Output format options in the Formula column article.
Result: the matching month name, for example "January" for a date in January.
Watch the default value: it must contain a space between the quotation marks (" "). An empty string ("") does not work.
Why use SWITCH instead of IF? SWITCH() replaces sequences of nested IF()s with logic that is more readable, easier to maintain, and less error-prone. It is recommended as soon as you need to handle more than 3 conditional cases.
Go further
IF
The simple IF... THEN... ELSE condition, for a single case.