Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
We value your feedback – take our 5-minute QlikView modernization survey
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Last 3 Years

I need to show only last 3 years in a listbox from the table below. Can someone tell me if I am writing this function correctly? Thanks so much in advance!!!! See the table below:

= if(fyear=currentyr, if(fyear=currentyr-1, if(fyear=currentyr-2, fyear)))

In Expressions box, this function shows no error but I don't see this working or showing only 2014, 2013, 2013 in the listbox.

fyearcurrentyr
Record 120092014
Record 220092014
Record 320102014
Record 420102014
Record 520112014
Record 620122014
Record 720112014
Record 820122014
Record 920132014
Record 1020132014
Record 1120142014
Record 1220142014
Record 1320142014


1 Solution

Accepted Solutions
mov
Employee
Employee

Try using calculated dimension instead of Record (assuming the filed name is Record):

aggr(if(fyear>=(currentyr-2), Record), Record)

View solution in original post

6 Replies
mov
Employee
Employee

Try using calculated dimension instead of Record (assuming the filed name is Record):

aggr(if(fyear>=(currentyr-2), Record), Record)

Not applicable
Author

See attached, I just used =if(currentyr - fyear <= 3, Record) as the expression for the list box.  Hope this helps!

Not applicable
Author

This one totally works!!! Thanks!!!

Not applicable
Author

I didn't try this one. The previous one worked for me. Thanks guys!!

suzel404
Creator
Creator

Hi npatnaik,

In straight table : Expression :

Only({<fyear={$(=Max({1}fyear)-2), $(=Max({1}fyear)-1), $(=Max({1}fyear))}>} fyear)

or

Only({<fyear={">=$(=Max(fyear)-2)<=$(=Max(fyear))"}>} fyear)


Not applicable
Author

Michael -- Can you help me solve this problem as well?? Your last answer was bang on!!!

Calculate Contribution % for last 3 Years only