Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
rnorris
Partner - Creator
Partner - Creator

Is it possible to use dynamic variables in the variable box of a button action?

kind of hard to explain without seeing it:

 

rnorris_0-1693948674534.png

This is what I'm trying to do. Here, vVarClause is a variable, that resolves to 'v$(x)Clause' where $(x) is a counter. The first action you can see is to increment the counter. So, initially, it evaluates as v0Clause. When you first click this button, it is v1Clause, and so, the second action (expanded here) should be to update the value for v1Clause. Clicking it again, it should update v2Clause, and so on. 

 

However, in practice, despite the little 'function' fx icon thingie to the right of the variable name box, it seems that putting any kind of expression in there does nothing? I've tried even putting in:

if($(x) = 1, v1Clause, if($(x) = 2, v2Clause)) 

and similar, this doesn't seem to work either. Looking at the evaluated code at the bottom of the screen in the editor, it seems to work, but in practice doesn't. 

Is what I'm trying to do possible? Like most of Qlik Sense, it feels really annoying and inconsistent. I have no idea if I've got the wrong syntax or if for some reason it just doesn't work the same way here as it does everywhere else. 

Labels (1)
1 Solution

Accepted Solutions
Javizh
Partner - Contributor III
Partner - Contributor III

Hello @rnorris 

I think the problem is your "Variable" input should be:

  • '$(vVarClause)'

With the single quotes.

Attached is an example where i made it work, I think i replicated your case.

Hope its helpful.

Best regards.

View solution in original post

3 Replies
Javizh
Partner - Contributor III
Partner - Contributor III

Hello @rnorris 

I think the problem is your "Variable" input should be:

  • '$(vVarClause)'

With the single quotes.

Attached is an example where i made it work, I think i replicated your case.

Hope its helpful.

Best regards.

rnorris
Partner - Creator
Partner - Creator
Author

Hmm, I'm fairly sure I tried with quotes, but possibly I tried with quotes and a preceding = sign? I'll give it a go later, thanks so much for your help! The community here really is amazing.

rnorris
Partner - Creator
Partner - Creator
Author

AH! Amazing! So, I had tried, but actually it was the other way around, I'd been trying 'without' the = sign, and looking at your code, you have it there! With that, it DOES work, awesome, thank you so much! With normal variable names, if you open the editor, Qlik inserts the = for you, which then breaks it, and you have to take it out yourself! I'd just fallen into the trap of doing that, I guess!