Skip to main content
Version: Streamsheets 3.0

SWITCH

The SWITCH Function switches values, by defining switch conditions and a default value if the switch conditions are not met. The amount of switch conditions is not limited.

Syntax

=SWITCH(LookupKey, KeyValue1, Value1, KeyValue2, Value2 ..., KeyValueN, ValueN, [DefaultValue])

Arguments

NameTypeDescription
LookupKeyValueKey to check
KeyValue1, Value1, KeyValue2, Value2 ..., KeyValueN, ValueNValueKey/Value pairs to find Key in.
DefaultValue (optional)ValueReturn value, if KeyValue is not found.

Return

TypeDescription
ValueDefault Value when switch condition is not met. ValueN, if LookupKey matched KeyValueN.

Examples

FormulaResultComment
=SWITCH(2, 1, "Sun", 2, "Mon", 3, "Tue", "None")
"Mon"The key 2 corresponds to the value "Mon".
=SWITCH(4, 1, "Sun", 2, "Mon", 3, "Tue", "None")
"None"The key 4 could not be found.