Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Qlik1_User1
Specialist
Specialist

Get latest 5 year data only

HI All,

I am using this expression

=Aggr(if(Rank(Count(reporting_year))<6,reporting_year),reporting_year) this gives me latest 5 year data.

But as soon as i select reporting year from filter, in bar chart only selected year is coming.
Is there a way if user select any reporting year from filter , still latest 5 year data should be visible not the select reporting year.

Labels (3)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

Try below, for calculated dimension, but in this case you also need to modiy your measure to ignore selections in field reporting_year

Dimension

=Aggr(only({1<reporting_year={">$(=Max(reporting_year)-5)"}>}  reporting_year ),reporting_year) 

Measure

sum({<reporting_year= >} Sales)

 

 

Ideally you can restrict your measure instead of the dimension. for example

 

Dimension = reporting_year

Measure =

sum({<reporting_year={">$(=Max(reporting_year)-5)"} >} Sales)

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

1 Reply
vinieme12
Champion III
Champion III

Try below, for calculated dimension, but in this case you also need to modiy your measure to ignore selections in field reporting_year

Dimension

=Aggr(only({1<reporting_year={">$(=Max(reporting_year)-5)"}>}  reporting_year ),reporting_year) 

Measure

sum({<reporting_year= >} Sales)

 

 

Ideally you can restrict your measure instead of the dimension. for example

 

Dimension = reporting_year

Measure =

sum({<reporting_year={">$(=Max(reporting_year)-5)"} >} Sales)

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.