Skip to main content

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Skip the ticket, Chat with Qlik Support instead for instant assistance.
cancel
Showing results for 
Search instead for 
Did you mean: 
cpalbrecht
Creator
Creator

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
marcus_sommer
MVP & Luminary
MVP & Luminary

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

View solution in original post

19 Replies
sushil353
Master II
Master II

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

cpalbrecht
Creator
Creator
Author

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

marcus_sommer
MVP & Luminary
MVP & Luminary

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

- Marcus

cpalbrecht
Creator
Creator
Author

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

agigliotti
Partner - Master III
Partner - Master III

try the below statement:

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

on the UI use v2 without dollar expansion $.

marcus_sommer
MVP & Luminary
MVP & Luminary

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

trace $(v1);

trace $(v2);

trace '$(v2)';

- Marcus

cpalbrecht
Creator
Creator
Author

It is also not working:

Let v1 = 1;

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

Trace($(v2));

Let v1 = 2;

Trace($(v2));

qlikscreen.JPG

cpalbrecht
Creator
Creator
Author

Trace($(v1));

Trace($(v2));

Trace('$(v2)');

-->

(2)

(v1 is 1)

('v1 is 1')

agigliotti
Partner - Master III
Partner - Master III

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