Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all
I'm having a problem using variables in Qlik Sense Set Analysis.
I searched for similar questions but I couldn't find what I'm looking for.
I defined the following variables:
max_TIME as: Max(TIME) (it returns max year)
maxval as: sum({$<TIME = {$(max_TIME)}>} Value) (it should return the aggregated value of "Value" measure corresponding to max year)
I tested the first one (max_TIME) and it's working fine.
The issue is with the second one (maxval), since it's not returning the right value (it always returns the wrong value 0, no matter what's the TIME I select).
If I change maxval this way
sum({$<TIME = {2007}>} Value)
it works fine, so I guess the problem is with the evaluation of variable max_TIME within variable maxval.
Should I use a different syntax?
Is there some kind of limitation in Qlik Sense when it comes to this feature?
Any help would be highly appreciated!
Regards
In the qvf you uploaded, max_TIME is defined as a master measure, not a variable.
Master Measures cannot reference other master measures. So
sum({$<TIME={$(=$(max_TIME))}>} Value)
will not work, as max_TIME is a master measure, not a variable.
-Rob
I suggest you try this:
Replace
sum({$<TIME = {$(max_TIME)}>} Value)
... by...
sum({$<TIME = {$(=max_TIME)}>} Value)
Hi Onno
I tried your hint, but it's still not working (it returns 0 instead of the right value).
regards
I wonder what the actual script is you are using the set the values for those variables. Could you show us?
I would not be surprised if that is where things are actually going wrong.
Hi Onno
I attach a Test application (TEST_APP.qvf) showing the issue.
The 4 variables were created using the GUI, not the script.
min_TIME and max_TIME return right results, while minval and maxval don't work.
Thank you!
Hi Onno
in addition to the Qlik Sense example TEST_APP.qvf I posted some days ago in this thread, I tried the following expressions:
minval as: sum({$<TIME={$(=$(min_TIME))}>} Value)
maxval as: sum({$<TIME={$(=$(max_TIME))}>} Value)
which worked fine in QlikView 12 (I attach the example) but don't seem to work in Qlik Sense (they return 0, no matter the selection).
Best regards,
Francesco
Not near a PC that actually has both Qlik products installed (so I can't check), but to my knowledge most of the things that work in QlikView should work (and the same way) in Qlik Sense.
I kinda hoped others would have also jumped this topic and point out a silly typo or something. I still hope they do.
In the qvf you uploaded, max_TIME is defined as a master measure, not a variable.
Master Measures cannot reference other master measures. So
sum({$<TIME={$(=$(max_TIME))}>} Value)
will not work, as max_TIME is a master measure, not a variable.
-Rob
Rob thank you so much for the answer!
I defined max_TIME as a variable, then I changed maxval definition to:
sum({$<TIME={$(=$(max_TIME))}>} Value)
Now it shows the right result.
Best regards,
Francesco