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

Returns the value based on the first matching item.

expressionThe expression to be compared to the values.
value1The value to compare.
result1The result if the expression equals the value.
value2(Optional) The value to compare.
result2(Optional) The result if the expression equals the value.
default(Optional) The value to return when there are no matches.

Remarks

* Added in Excel 2019.
* The "values" can be numbers or text.
* The "results" can be any expression.
* If none of the "values" match and a "default" value has been provided, then the default value is returned.
* If none of the "values" match and a "default" value has not been provided, then #N/A! is returned.
* You can have a maximum of 126 (values and results).
* If the function is not available, then #NAME? is returned.
* For the Microsoft documentation refer to support.office.com

 A
1=SWITCH(1,1,"London",2,"New York") = London
2=SWITCH(2,1,"London",2,"New York") = New York
3=SWITCH("findtokyo",1,"London","findtokyo","Tokyo") = Tokyo
4=SWITCH("Tokyo","London",1,"Tokyo",2) = 2
5=SWITCH("Tokyo","London",1,"Tokyo",2,"Tokyo",3) = 2
6=SWITCH("findtext",1,"London",2,"New York","no match") = no match
7=SWITCH("findtext",1,"London",2,"New York") = #N/A
8=SWITCH(3,1,"London",2,"Paris") = #N/A

1 - What is the first result where the value matches the number "1".
2 - What is the first result where the value matches the number "2".
3 - What is the first result where the value matches the string "findtokyo".
4 - What is the first result where the value matches the string "Tokyo".
5 - What is the first result where the value matches the string "Tokyo".
6 - What is the first result where the value matches the string "findtext". This value is not found so the default value is returned.
7 - What is the first result where the value matches the string "findtext". The value is not found and no default value has been provided.
8 - What is the first result where the value matches the number "3". The value is not found and no default value has been provided.

© 2019 Better Solutions Limited. All Rights Reserved. © 2019 Better Solutions Limited Top