6 Replies Latest reply: Jun 5, 2014 8:59 PM by Nihar Pattnaik

# 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.

 fyear currentyr Record 1 2009 2014 Record 2 2009 2014 Record 3 2010 2014 Record 4 2010 2014 Record 5 2011 2014 Record 6 2012 2014 Record 7 2011 2014 Record 8 2012 2014 Record 9 2013 2014 Record 10 2013 2014 Record 11 2014 2014 Record 12 2014 2014 Record 13 2014 2014

• ###### Re: Last 3 Years

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

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

• ###### Re: Last 3 Years

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

• ###### Re: Last 3 Years

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

• ###### 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)