Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

cpalbrecht
Contributor

Dynamic variable in String

Hi,

I have a variable in a String. And I want the String to change when the variable changes.

Let v1 = 1;

Let v2 = 'v1 is $(v1)';

$(v2) --> "v1 is 1"

When I change v1, I want also v2 to be changed:

Let v1 = 2;

$(v2) --> "v1 is 2"

But it doesn't work. It works only the first time I use $(v2). Do you know how to do that?

BR

1 Solution

Accepted Solutions

Re: Dynamic variable in String

I think you could use parametrized variables for it - maybe something like this:

let v1 = 'select * from SOURCE where Date >= $1;';

let v2 = '$(v1(''20.12.2017''))';

trace $(v1);

trace $(v2);

- Marcus

19 Replies
sushil353
Honored Contributor II

Re: Dynamic variable in String

Try this: Let v2 = 'v1 is'& $(v1);

cpalbrecht
Contributor

Re: Dynamic variable in String

That is also not working. Its the same result. The string is only evaluated once :/

Re: Dynamic variable in String

How do you call the variable - with $(v2) or with '$(v2)' and where?

- Marcus

cpalbrecht
Contributor

Re: Dynamic variable in String

I tried both $(v2) and '$(v2)'. I'm using the variables in the data load script.

agigliotti
Honored Contributor II

Re: Dynamic variable in String

try the below statement:

Let v2 = '=v1 is ' &  $(v1);

on the UI use v2 without dollar expansion $.

Re: Dynamic variable in String

How do you check the content of the variables? Did you try:

trace $(v1);

trace $(v2);

trace '$(v2)';

- Marcus

cpalbrecht
Contributor

Re: Dynamic variable in String

It is also not working:

Let v1 = 1;

Let v2 = '=v1 is ' & $(v1);

Trace($(v2));

Let v1 = 2;

Trace($(v2));

qlikscreen.JPG

cpalbrecht
Contributor

Re: Dynamic variable in String

Trace($(v1));

Trace($(v2));

Trace('$(v2)');

-->

(2)

(v1 is 1)

('v1 is 1')

agigliotti
Honored Contributor II

Re: Dynamic variable in String

what do you get on the UI creating a Text object with expression =v2 ?

Community Browser