Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

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



Tags (2)
1 Solution

Accepted Solutions
Not applicable

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

Got it. Actually there was nothing wrong in this particular part of the script. The script that uses this part later was faulty and the error message was confusing.

3 Replies
alexandros17
Not applicable

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

this expression can be written with

LET v_COP_reg_vnum_YTD_cur_temp = 'v_COP_reg_vnum_YTD_'&$(v_cur_period);

SET ......

I cannot understand This other
LET $(v_COP_reg_vnum_YTD_cur_temp) = 'sum({$<[Data Snapshot Date]  = {'&$(v_cur_period)&'}>}[FP1 Stat.Reg. Price])';

Not applicable

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

Actually now when I think of my workaround it does exactly same thing as my actual problem - using variable including function as a name so nevermind that. :/

SET might be better but doesn't affect the problem.

Not applicable

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

Got it. Actually there was nothing wrong in this particular part of the script. The script that uses this part later was faulty and the error message was confusing.