Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

thnkgreen
Contributor

Specific Example of Switch Case statement

Hello my friends.  I have had no luck so far in finding a specific working example of a SWITCH CASE statement as used in QlikView.  I have added my original sample code below.  Will someone please kindly re-write and then explain how this code would look and work as a SWITCH CASE statement.  Thank you.

          CASE
                WHEN PSWHSE = 001 THEN TRIM(PSAREA) || TRIM(PSZONE) || LEFT(TRIM(PSAISL,1)) || TRIM(PSBAY)
                WHEN PSWHSE = 003 THEN TRIM(PSAISL) || TRIM(PSLEVL) || TRIM(PSPOSN)
                WHEN PSWHSE = 031 THEN TRIM(PSAISL) || TRIM(PSLEVL) || TRIM(PSPOSN)
           END
           AS RESERVELOCATION

Tags (1)
1 Solution

Accepted Solutions
MVP
MVP

Re: Specific Example of Switch Case statement

Maybe like this?

pick(match(PSWHSE,001,003,031)

,  TRIM(PSAREA) & TRIM(PSZONE) & LEFT(TRIM(PSAISL,1)) & TRIM(PSBAY)

,  TRIM(PSAISL) & TRIM(PSLEVL) & TRIM(PSPOSN)

,  TRIM(PSAISL) & TRIM(PSLEVL) & TRIM(PSPOSN)
)   AS RESERVELOCATION

within a LOAD.

5 Replies
Not applicable

Re: Specific Example of Switch Case statement

MVP
MVP

Re: Specific Example of Switch Case statement

Maybe like this?

pick(match(PSWHSE,001,003,031)

,  TRIM(PSAREA) & TRIM(PSZONE) & LEFT(TRIM(PSAISL,1)) & TRIM(PSBAY)

,  TRIM(PSAISL) & TRIM(PSLEVL) & TRIM(PSPOSN)

,  TRIM(PSAISL) & TRIM(PSLEVL) & TRIM(PSPOSN)
)   AS RESERVELOCATION

within a LOAD.

thnkgreen
Contributor

Re: Specific Example of Switch Case statement

This is exactly what I was looking for. Thank you so much!!!!!! ☺

nehasaxena
Contributor II

Re: Specific Example of Switch Case statement

Is it possible to add Else condition in this expression.

Thanks,

Neha

anbu1984
Honored Contributor III

Re: Re: Specific Example of Switch Case statement

Try this

pick(match(PSWHSE,001,003,031)+1

        ,    else_expression

    ,  TRIM(PSAREA) & TRIM(PSZONE) & LEFT(TRIM(PSAISL,1)) & TRIM(PSBAY)

    ,  TRIM(PSAISL) & TRIM(PSLEVL) & TRIM(PSPOSN)

    ,  TRIM(PSAISL) & TRIM(PSLEVL) & TRIM(PSPOSN)

)