Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I am having some trouble understanding the dollar sign expansion.
5
//test
The comment in the last line is intended and part of my confusion.
Expression: $(vTest)
Result: 5
Internal: I guess that QS expands this to the following and evaluates the complete expression afterwards:
5
//test
Expression: $(vTest) / 2
Result: 5
Internal: I guess that QS expands this to the following and evaluates the complete expression afterwards:
5
//test / 2
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
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?
As noone has answered this yet: Is this because you do not have an answer or is my question unclear?
Or maybe it's because you just posted the question 3 minutes before awaiting a response?
Well, this is a public forum with only volunteers answering your questions, you just need to wait a little longer.
If you put your expressions in a straight table expression and hover the mouse over the label, you see the expanded dollar signs.
This should explain how Qlik works..
Stefan Wühl wrote:
Or maybe it's because you just posted the question 3 minutes before awaiting a response?
Well, this is a public forum with only volunteers answering your questions, you just need to wait a little longer.
Hi Stefan,
I posted this question last week. I just edited some typos. Unfortunately this board does not show creation date and last edit date.
Thanks for the input with the straight tables' mouseover. I will play arround with it a little an see if that explains the behaviour to me.
All the best
Oliver
Well, then skip my first two lines.
If you look at my first screenshot, you'll notice that =vTest used in an expression will return the text, not the numeric value of the variable.
If you already create your variable using the equal sign, it will hold the number.
Lesson to learn: Be extremely cautious using comments in variables
Dear Stefan,
it looks like QS ist handling this different than QV does.
This still does not help me to understand why $(=vTest) is NOT evaluated FIRST before it is divided by 2.
It even gets weird:
=vTest breaks when I add another Column for vTest. The screenshot is taken from one Sheet with two tables.
If
=vTest
is returning the text:
'5 //test'
then why should $(=vTest) return anything other than the text?
It should work (though it would not be intuitive to use) either using
=$(=$(=vTest)) / 2
or adding a line break after the dollar sign expansion
=$(=vTest)
/2
I'm not sure that I could comprehend what the aim for your scenarios is. Like Stefan hinted you need to be very carefully with comments within the variables - and if /* comment */ will be better than just // - especially as it adds no value else it is just potentially trouble causing.
- Marcus
Adding to Marcus comment, in QlikView, there is a separate space in variable overview to enter a comment per variable, storing the comment to the meta data.
Is there something similar in QlikSense? I am not sure, currently working with QlikView only.
Hi Stefan,
just a little background info: While you are only working with QV, I am only working with QS. I don't know about variable handling in QV but in QS it is a lot of trial end error when it comes to complex variables that reference other variables within. With this I am trying to understand the underlying mechanics a little more to reduce the trial an error time.
Your answer absolutelty makes sense. If =vTest returns '5 //comment' $(=vTest) should expand to exactly this.
And it looks like it does behave this way for $(=vTest) / 2 as the result is 5. So propably it expands to
'5
//comment / 2.'
So why does this logic not apply to $(=vTest) (without /2). I would expect that the result is
'5
//coment'
Because this is the result of =vTest.
Instead of this the result is the number 5.