Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

kidbank3
Contributor III

Dynamic Variable Name

Is it possible to set a variable name to include the current year?

For example:

set vCurrentYear=year(today());

set v&$(vCurrentYear)&Parm1 = .05;

I want this to evaluate to v2016Parm1=.05.

Thanks,

Mike

1 Solution

Accepted Solutions

Re: Dynamic Variable Name

You are right. I totally misread the question. I believe the solution would be:

Let vCurrentYear=year(today());

set v$(vCurrentYear)Parm1 = .05;

-Rob

7 Replies

Re: Dynamic Variable Name

LET vMyVar = 'v' & $(vCurrentYear)& 'Parm1 = .05';


-Rob

http://masterssummit.com

http://qlikviewcookbook.com

alexdataiq
Contributor III

Re: Dynamic Variable Name

So wouldn't this create a vMyVar variable with 'v2016Parm1 = .05' as value instead of a v2016Parm1 variable with '.05' as value?

Or you just need to use $(vMyVar) in place of the whole variable in the desired expression?

Regards

Re: Dynamic Variable Name

You are right. I totally misread the question. I believe the solution would be:

Let vCurrentYear=year(today());

set v$(vCurrentYear)Parm1 = .05;

-Rob

kidbank3
Contributor III

Re: Dynamic Variable Name

Thanks Rob, 

The proper syntax was really getting me here and I couldn't find another post on this. 

I really appreciate it.

Mike

kidbank3
Contributor III

Re: Dynamic Variable Name

I have one additional question about this topic: Does my variable need to be script defined?  I tried defining it in the app and couldn't get it to evaluate correctly. 

Thanks,

Mike

Re: Dynamic Variable Name

I don't think there is any way to use a dynamic variable name from the UI Variable Overview.

-Rob

kidbank3
Contributor III

Re: Dynamic Variable Name

Thanks for confirming

Community Browser