Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

francesco_gregori
New Contributor

Variables in Qlik Sense Set Analysis

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

1 Solution

Accepted Solutions

Re: Variables in Qlik Sense Set Analysis

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

http://masterssummit.com

http://qlikviewcookbook.com

8 Replies
oknotsen
Honored Contributor III

Re: Variables in Qlik Sense Set Analysis

I suggest you try this:

Replace

sum({$<TIME = {$(max_TIME)}>} Value)

... by...

sum({$<TIME = {$(=max_TIME)}>} Value)

May you live in interesting times!
francesco_gregori
New Contributor

Re: Variables in Qlik Sense Set Analysis

Hi Onno

I tried your hint, but it's still not working (it returns 0 instead of the right value).

regards

oknotsen
Honored Contributor III

Re: Variables in Qlik Sense Set Analysis

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.

May you live in interesting times!
francesco_gregori
New Contributor

Re: Variables in Qlik Sense Set Analysis

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!

francesco_gregori
New Contributor

Re: Variables in Qlik Sense Set Analysis

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

oknotsen
Honored Contributor III

Re: Variables in Qlik Sense Set Analysis

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.

May you live in interesting times!

Re: Variables in Qlik Sense Set Analysis

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

http://masterssummit.com

http://qlikviewcookbook.com

francesco_gregori
New Contributor

Re: Variables in Qlik Sense Set Analysis

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

Community Browser