1 Reply Latest reply: Mar 5, 2017 11:47 AM by Sunny Talwar RSS

    WHEN CASE in script

    lala lala

      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')


               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)



      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)



                Case when Flag_2='ES'

                     Then (hours*1/12)

                     else (hours*1/15)




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

                          Then 0.5

                          else 1




      As NEW_FIELD,



      Thanks for your help!

        • Re: WHEN CASE in script
          Sunny Talwar

          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(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