Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

mwallman
Contributor

Can anyone teach me an Intermediate example of Switch...Case statement please?

Hello all,

Can anybody please show an example of Switch Case statement and how it works with an intermediate-advanced example for some data?

I would like to understand it better

3 Replies
sureshqv
Esteemed Contributor III

Re: Can anyone teach me an Intermediate example of Switch...Case statement please?

MVP
MVP

Re: Can anyone teach me an Intermediate example of Switch...Case statement please?

The switch is a script control structure that functions like a series elseif statements:

if ... then ...

elseif ...

elseif ...

elseif ...

...

else ...

end if

switch <expression>

case 1               // execute if statement evaluates to 1

     ...

case 2               // execute if statement evaluates to 2

     ...

default               // execute if no case statement match (like a final "else")

     ...

end switch

Unlike mainstream programming languages, there is no "break" statement. Each "case" is an implicit break for the case above.

PS - I don't think i have ever used it in a real application, but YMMV

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
mwallman
Contributor

Re: Can anyone teach me an Intermediate example of Switch...Case statement please?

Hi,

Thank you for the replies but I am still not finding a practical example. Could someone share a practical one please?

Why would you use Switch Case statements? What are the advantages and disadvantages of this function?

Community Browser