# Switch..case..default..end switch

The switch control statement is a script selection construct forcing the script execution to follow different paths, depending on the value of an expression.

Syntax:

Switch expression {case valuelist [ statements ]} [default statements] end switch

Information noteSince the switch statement is a control statement and as such is ended with either a semicolon or end-of-line, each of its four possible clauses (switch, case, default and end switch) must not cross a line boundary.

Arguments:

Switch arguments

| Argument | Description |
| --- | --- |
| expression | An arbitrary expression. |
| valuelist | A comma separated list of values with which<br>the value of expression will<br>be compared. Execution of the script will continue with the statements<br>in the first group encountered with a value in valuelist<br>equal to the value in expression.<br>Each value in valuelist may be<br>an arbitrary expression. If no match is found in any case<br>clause, the statements under the default<br>clause, if specified, will be executed. |
| statements | Any group of one or more QlikView script<br>statements. |

Example:

`Switch I` `Case 1` `LOAD '$(I): 
 CASE 1' as case autogenerate 1;` `Case 2` `LOAD '$(I): 
 CASE 2' as case autogenerate 1;` `Default` `LOAD  '$(I): 
 DEFAULT' as case autogenerate 1;` `End Switch`

## Learn more

* [End](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptControlStatements/End.htm)