Qlik Community

Ask a Question

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Talk to Experts Tuesday, January 26th at 10AM EST: Qlik Sense. REGISTER NOW
Showing results for 
Search instead for 
Did you mean: 
Contributor III
Contributor III

Switch case example


i am using qlik sense desktop and i want to see example of using Switch..case..default..end switch as it is very helpful in creating the reports.

2 Replies

Hi, have you seen the help, it has a really good example.

     Switch..case..default..end switch ‒ Qlik Sense


Switch I

Case 1

LOAD '$(I): CASE 1' as case autogenerate 1;

Case 2

LOAD '$(I): CASE 2' as case autogenerate 1;


LOAD '$(I): DEFAULT' as case autogenerate 1;

End Switch



After a while, it finally clicked how it worked for me. Allow me to share this example; I use switch to define a variable depending on whether or not the variable 'vSchemaName' is filled. 


Let vLenSchemaName=len('$(vSchemaName)'); //I create a variable, measuring the length of the  schemaname.

Switch vLenSchemaName 
    case 0 //So, there is no schemaname, the value of the 'switch'-variable is 0.
            Let vTableNameCaps=UPPER('$(vTableNamePrefix)$(vTableName)' );
    default //So, there is a schemaname; 
            Let vTableNameCaps=UPPER('$(vTableNamePrefix)$(vSchemaName)_$(vTableName)' );

end switch;