0 Replies Latest reply: Jan 3, 2013 12:49 PM by Jeannie Chi RSS

    How to use sql case-when with multiple variables from different tables , and store into new variable in qlikview

      I am trying to create new variable "new_var" base on condition that derived from 2 variables / 2 different tables in sql .. so If I use sql I would use something like :


      select id,

               case when a.v1 in (1,2,3) then 'x'

                       when b.v2 in (1,2,3) then 'y'

               end as new_var

      from  a

      join  b on a.id = b.id


      I'm new to qlikview , so now I have to get two different tables to two different loads using these below



      load id , v1;

      sql select id, v1

           from a;

      store T_a into T_a.qvd(qvd);



      load id , v2;

      sql select id, v2

           from b;

      store T_b into T_b.qvd(qvd);




      Is there a way I can create "new_var" based on variabvle v1 from table a & variable v2 from table b to get "new_var" ?


      Thank you ~