Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
john_delligatti
Luminary
Luminary

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
sunny_talwar

How about this

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

View solution in original post

4 Replies
sunny_talwar

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

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

john_delligatti
Luminary
Luminary
Author

Hi Sunny,

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

sunny_talwar

How about this

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

john_delligatti
Luminary
Luminary
Author

That did it! Thank you!!