
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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;
