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.

Announcements
March 11, 2PM EST: Do More with Qlik - Getting Started wtih Qlik Sense SaaS - Redux. REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
ebrahimaljefri
Contributor III
Contributor III

Switch case example

hi,

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
dberkesacn
Partner
Partner

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

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

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

Daniel

Lemac
Contributor
Contributor

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;