Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Can we write switch case statement instead if-else while creating calculated columns?

Hi All,

I need to create one calculated column and I am able to create using if-else statement:

if(x=1,'XYZ1',

if(x=2,'XYZ2',

if(x=3,'XYZ3',

if(x=4,'XYZ4',

if(x=5,'XYZ5',

if(x=6,'XYZ6',

if(x=7,'XYZ7',

if(x=8,'XYZ8',

if(x=9,'XYZ9',

if(x=10,'XYZ10',

if(x=11,'XYZ11',

if(x=12,'XYZ12',

'Other'))))))))))))

I tried to replace the if-else statement with switch case statement but could not able to do. I am very new to Qlick Sense. Could you please suggest me that is that possible to write a switch statement while creating calculated column? If Yes please give me sample script snippet by considering above if-else statement example.

1 Reply
Kellerassel
Partner - Contributor III
Partner - Contributor III

You cannot use switch..case inside a load statement. It is a control statement to force execution of one code of block or another depending on a condition. 

But you could shorten your statement down like this:

Load If(x < 13, 'XYZ' & x, 'Other') as yourcolumn
....