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: 
Oliver_F
Partner - Creator III
Partner - Creator III

Dollar sign expansion not working as expected

Hi,

I am having some trouble understanding the dollar sign expansion.

Variable Definition of vTest

5

//test

The comment in the last line is intended and part of my confusion.


Scenario 1

Expression: $(vTest)

Result: 5

Internal: I guess that QS expands this to the following and evaluates the complete expression afterwards:

5

//test


Scenario 2

Expression: $(vTest) / 2

Result: 5

Internal: I guess that QS expands this to the following and evaluates the complete expression afterwards:

5

//test / 2


Scenario 3

Expression:

$(vTest)

/ 2

Result: 2.5

Internal: I guess that QS expands this to the following and evaluates the complete expression afterwards:

5

//test

/ 2

Scenario 4 - This is what confuses me

Expression: $(=vTest) / 2

Result: 5

Internal: I have no idea what happens here internally. According to the Qlik documentation the equal sign should cause Qlik to pre-evaluate the variable and use the result for the expression.

The expression will be evaluated and the value will be used in the expansion.

So what I would have expected is, that Qlik evaluates $(=vTest) to 5 and then divides it by 2, so the result should be 2.5 and not 5.


Do you have any explanation for what Qlik is doing in my Scenario 4?


15 Replies
swuehl
MVP
MVP

Guess that's because after the dollar sign expansion, the expression evaluation kicks in, ignoring the comment the same way it will ignore a comment if you input the variable content directly as expression in the chart expression space.

While using =vTest, expanding the variable content including the comment is part of the expression evaluation.

marcus_sommer

I think you are paying the price for overusing the variable-feature. Only that it is in general possible to use for nearly everything variables and thats even technically possible to nest multiple variables doesn't mean that it's sensible to do it. Variables should simplify things and not result in the opposite. Just keep it simple.

- Marcus

swuehl
MVP
MVP

Adding to your first remark in your last post:

I do work with QS also, but not today.

Just to make sure, have you read HICs blog posts about variable evaluation?

Like

The Little Equals Sign

Oliver_F
Partner - Creator III
Partner - Creator III
Author

Hi Stefan,

I read the The Little Equals Sign article several times in the past.

Additionally those two articles are great.

The Magic of Variables

The Magic of Dollar Expansions

I would like to thank you for all the input so far and might get back to you after I have tested some more things to understand what is going on in detail.

swuehl
MVP
MVP

Yes, all of Henric's posts are a must-read IMHO, these two blog posts are linked in the first post, so I've refrained from posting the links.

t_witzgall
Partner - Contributor III
Partner - Contributor III

There is indeed a separate space for a description:

variable_definition.png

I never used this before .. probably I should in the future ..