SWITCH Function
The SWITCH function is one of the logical functions. It is used to evaluate one value (called the expression) against a list of values, and returns the result corresponding to the first matching value. If there is no match, an optional default value may be returned.
The SWITCH function syntax is:
SWITCH(expression, value1, result1 [, [default or value2] [, [result2]], ...[default or value3, result3]])
where
expression is the value that will be compared against value1 ...value126.
value1 ...value126 is the value that will be compared against expression.
result1 ...result126 is the result to be returned if the value1 ...value126 matches to the expression.
default is the result to be returned if there are no matches. If the default argument is not specified and there are no matches, the function returns the #N/A error.
Note: you can enter up to 254 arguments i.e. up to 126 pairs of values and results.
To apply the SWITCH function,
- select the cell where you wish to display the result,
- click the Insert function icon situated at the top toolbar,
or right-click within a selected cell and select the Insert Function option from the menu,
or click the icon situated at the formula bar, - select the Logical function group from the list,
- click the SWITCH function,
- enter the required arguments separating them by commas,
- press the Enter button.
The result will be displayed in the selected cell.