Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Highlighted
jumiprado
Contributor

WHEN CASE in script

Hey guys! I need your help with WHEN CASE Expression in the script. I have a piece of code with expressions when and case to generate a new field and I would need to be able to translate it in the best way to use it in the Qlikview script.

When Flag_1='M' or (Flag_2='PM' and Flag_1='C')

     then

         Case when left(Flag_3,1)='I' or (Flag_4='A' and Flag_2='AM')

               Then (hours*1/18)

     Else Case when Flag_2='ES'

               then (hours*1/12)

               else (hours*1/10)

END

When Flag_1='H' then

     case when left(Flag_3,1)='I' then

          Case when Flag_2='AC'

               then (hours*1/14)

               else (hours*1/12)

    

          When left(Flag_3,1)='A' then

               Case when Flag_2='AC' then (hours*1/14)

                         When Flag_2='EH' then (hours*1/15)

                   

                                   else (hours*1/12)

     else

          Case when Flag_2='ES'

               Then (hours*1/12)

               else (hours*1/15)

          end

     Else Case when Flag_2='TM' and left(Flag_3,1)='A'

                    Then 0.5

                    else 1

                    END

          END

As NEW_FIELD,

Thanks for your help!

1 Solution

Accepted Solutions

Re: WHEN CASE in script

May be this:

If(Flag_1 = 'M' or (Flag_2 = 'PM' and Flag_1 = 'C'),

     If(Left(Flag_3,1) = 'I' or (Flag_4 = 'A' and Flag_2 = 'AM'), (hours*1/18),

     If(Flag_2 = 'ES', (hours*1/12), (hours*1/10))),

If(Flag_1='H',

     If(Left(Flag_3,1) = 'I',

          If(Flag_2 = 'AC', (hours*1/14), (hours*1/12)),

     If(Left(Flag_3,1) = 'A',

          If(Flag_2 = 'AC', (hours*1/14),

               If(Flag_2='EH', (hours*1/15), (hours*1/12))),

          If(Flag_2 = 'ES', (hours*1/12), (hours*1/15)))),

If(Flag_2 = 'TM' and left(Flag_3,1) = 'A', 0.5, 1))) as NewField

1 Reply

Re: WHEN CASE in script

May be this:

If(Flag_1 = 'M' or (Flag_2 = 'PM' and Flag_1 = 'C'),

     If(Left(Flag_3,1) = 'I' or (Flag_4 = 'A' and Flag_2 = 'AM'), (hours*1/18),

     If(Flag_2 = 'ES', (hours*1/12), (hours*1/10))),

If(Flag_1='H',

     If(Left(Flag_3,1) = 'I',

          If(Flag_2 = 'AC', (hours*1/14), (hours*1/12)),

     If(Left(Flag_3,1) = 'A',

          If(Flag_2 = 'AC', (hours*1/14),

               If(Flag_2='EH', (hours*1/15), (hours*1/12))),

          If(Flag_2 = 'ES', (hours*1/12), (hours*1/15)))),

If(Flag_2 = 'TM' and left(Flag_3,1) = 'A', 0.5, 1))) as NewField