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: 
Not applicable

Switch Statement

Hi,

Could someone help me with the correct syntax for Switch statement?

I have read through the forum threads on Switch statement but there doesn't seem to be any error free syntax.

Thanks,

DK

5 Replies
Not applicable
Author

Well the normal syntax is

switch variable

case 1

case 2

end switch

What do you need else regarding switch feature ?

Rgds,

Sébastien

Not applicable
Author

Hi Sebastien,

Thanks for that.

I have applied the syntax as you have given. But the above syntax doesnt work. It returns a 'Line Error' and I know that I have not made any other mistakes in the query.

dk

Not applicable
Author

Coud you paste the copy of the script ?

Miguel_Angel_Baeyens

Hi,

Do you end your case statements with semicolon?

switch expr
case first_possible_value_of_expr
do something;
case second_possible_value_of_expr
do something else;
default
do otherwise;
end switch




Is your "do something" statements length more than one line?

Not applicable
Author

Here is a simple example which works:



let

expr =2

;

switch

expr

case

2

TOTO:



LOAD

* INLINE

[

;



default

TOTO:

LOAD

* INLINE

[

;



end

switch