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: 
subbareddykm
Creator II
Creator II

Max 5 values

Hi i have one field,in that i want max five .

Load * Inline [

 

      Year
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017

] ;

Output :

2013
2014
2015
2016
2017

If i enter to next year i.e 2018 my output should be

2014
2015
2016

2017

2018

How to gyt this ?

3 Replies
sunny_talwar

May be this:

Table:

Load * Inline [

Year

2007

2008

2009

2010

2011

2012

2013

2014

2015

2016

2017

];

Right Join

LOAD Max5 + IterNo() as Year

While Max5 + IterNo() <= Max;

LOAD Max(Year) as Max,

  Max(Year) -5 as Max5

Resident Table;

Not applicable

Temp:

Load * Inline [

Year

2007

2008

2010

2009

2011

2012

2013

2014

2015

2016

2017

] ;

Temp1:

Load *,

RecNo() as Record

Resident Temp

order by Year desc;

drop table Temp;

Final:

Load Year

where Record < 6;

Load *

Resident Temp1;

Drop table Temp1;

subbareddykm
Creator II
Creator II
Author

But my year should give all years  and i want one more field with max five years with link to my year field