Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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

1 Solution

Accepted Solutions
swuehl
MVP
MVP

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.

View solution in original post

5 Replies
Not applicable
Author

swuehl
MVP
MVP

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.

Anonymous
Not applicable
Author

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

nehasaxena
Creator II
Creator II

Is it possible to add Else condition in this expression.

Thanks,

Neha

anbu1984
Master III
Master III

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)

)