Qlik Community

Qlik Sense App Development

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

john_delligatti
New Contributor II

Variables and Set Analysis

Hi All,

I am attempting to use a variable for max year in order to create a chart showing year over year pricing increases in Qliksense. I've successfully created the chart using  if( Year='2017',avg( [Unit Price],)) , same with 2016 and so forth. That said my boss is encouraging me to use variables to accomplish this to get familiar with them for future use.

I have the variable name set to vCurrentYr, with the variable set to max([Year])

To ensure I created the variable correctly I dropped it into a KPI box and it returned 2017, the max year from my data set.

However, when I enter the variable into my equation, I cannot for the life of me get it to work. The equation I've created is  avg({$<[Year]={$(vCurrentYr)}>}[Unit Price])

I've looked at all the posts I can find in this forum as well as youtube videos, as far as I can tell the syntax is correct. Would someone be able to assist?

Thank you.

1 Solution

Accepted Solutions

Re: Variables and Set Analysis

How about this

Avg({$<[Year]={$(=$(vCurrentYr))}>}[Unit Price])

4 Replies

Re: Variables and Set Analysis

Try to add an equal sign after the parenthesis within the dollar sign expansion

Avg({$<[Year]={$(=vCurrentYr)}>}[Unit Price])

john_delligatti
New Contributor II

Re: Variables and Set Analysis

Hi Sunny,

Thank you for your reply. Unfortunately it did not solve the issue, the equation returns blank.

Re: Variables and Set Analysis

How about this

Avg({$<[Year]={$(=$(vCurrentYr))}>}[Unit Price])

john_delligatti
New Contributor II

Re: Variables and Set Analysis

That did it! Thank you!!

Community Browser