Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
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])';



1 Solution

Accepted Solutions
Not applicable
Author

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.

View solution in original post

3 Replies
alexandros17
Partner - Champion III
Partner - Champion III

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
Author

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
Author

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.