3 Replies Latest reply: Jul 22, 2014 2:19 AM by Erno Bister RSS

    Dynamic naming of variables (LET) with evaluating right side of expression

      Hello all!

      This is my first post to Qlik Community.

       

      I need to create a variable with a spesific set expression each month. To my understanding this requires generating the variable name with a function as well as defining period to a set expression with a function.  The problem seems to be that I cannot have funtions on either side of the LET expression. I tried to work around this with no success.

       

      Any ideas why this might be occurring?

       

      BR,

      Erno

       

      LET v_cur_period=year(today()) & date(today(),'MM');

      // The above script gives: 201407

      //I can have :
      LET "v_COP_reg_vnum_YTD_$(v_cur_period)" = 1;

      //OR
      LET v_COP_reg_vnum_YTD_201407 = 'sum({$<[Data Snapshot Date]  = {'&$(v_cur_period)&'}>}[FP1 Stat.Reg. Price])';

      //But not the following:
      LET "v_COP_reg_vnum_YTD_$(v_cur_period)" = 'sum({$<[Data Snapshot Date]  = {'&$(v_cur_period)&'}>}[FP1 Stat.Reg. Price])';

      //I tried to work around this with no effect:
      LET v_COP_reg_vnum_YTD_cur_temp = 'v_COP_reg_vnum_YTD_'&$(v_cur_period);
      LET $(v_COP_reg_vnum_YTD_cur_temp) = 'sum({$<[Data Snapshot Date]  = {'&$(v_cur_period)&'}>}[FP1 Stat.Reg. Price])';