Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Highlighted
Arjunarao
Honored Contributor II

switch control statement

Hi All,

I am not clear about switch control statement.

Please give an example to Switch.

Thanks in advance.

2 Replies
Employee
Employee

Re: switch control statement

This is from the QlikView help.

If I evaluates to 1, the first load statement is executed, if I evaluates to 2 the second load statement is executed and in any other case the third load statement is executed.

Examples:

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

neetha_p
Honored Contributor

Re: switch control statement

Hi,

Switch control statement(conditional statement) used to control logical flow of script execution. Executes one of many choices,based on the value of an expression. If no match is found for the value, the DEFAULT statements are executed.

SWITCH I

CASE 1

[Executed when ‘I’ is 1]

CASE 2

[Executed when ‘I’ is 2]

CASE 3

[Executed when ‘I’ is 3]

DEFAULT

[Executed when ‘I’ is not 1 or 2 or 3]

END SWITCH

Examples:

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

Regards

Neetha