Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

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
Esteemed Contributor III

Re: Last 3 Years

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

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

6 Replies
mov
Esteemed Contributor III

Re: Last 3 Years

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

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

Not applicable

Re: Last 3 Years

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

Not applicable

Re: Last 3 Years

This one totally works!!! Thanks!!!

Not applicable

Re: Last 3 Years

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

suzel404
Contributor

Re: Last 3 Years

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

Re: Last 3 Years

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

Calculate Contribution % for last 3 Years only

Community Browser