Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

paulyeo11
Valued Contributor II

How to create a filter for show only 5 year data instead of 20 year data ?

Hi All

My QS Doc have last 20 year data.

I like to have a button to filter only analyse last 5 year data or 20 year data.

May i know how can i use it , instead of using 2 seperate Doc.

Paul

1 Solution

Accepted Solutions
ogster1974
Honored Contributor II

Re: How to create a filter for show only 5 year data instead of 20 year data ?

If its taking along time to do a simple filter selection why don't you create a bookmark of the predefined 5 year filter, call it last 5 years and save your app with the filter applied that way when you open the document its always filtered on the last 5 years.

Regards

Andy

7 Replies
MVP
MVP

Re: How to create a filter for show only 5 year data instead of 20 year data ?

May be use this as action -> Select in Field

Search String: ='>=' & Max({1}Year) - 4 & '<=' & Max({1} Year)

MVP
MVP

Re: How to create a filter for show only 5 year data instead of 20 year data ?

Just realized this is a Qlik Sense discussion. I am not very familiar with Qlik Sense Button actions, so not sure if what I prescribed will work or not

paulyeo11
Valued Contributor II

Re: How to create a filter for show only 5 year data instead of 20 year data ?

Hi Sir

QS have filter panel , but need to manually select year one by one very slow.

Paul

Sent from my iPhone

Not applicable

Re: How to create a filter for show only 5 year data instead of 20 year data ?

Hello,

I am not sure if I understood your issue, but you can try the following code:

if(Year>= START_YEAR and Year <= END_YEAR, Year)

Replace START_YEAR and END_YEAR as you need.

If the years are non consecutive you can try:

if(match(Year, 2000, 2005, 2010,2011), Year)

I hope it helps!

ogster1974
Honored Contributor II

Re: How to create a filter for show only 5 year data instead of 20 year data ?

If its taking along time to do a simple filter selection why don't you create a bookmark of the predefined 5 year filter, call it last 5 years and save your app with the filter applied that way when you open the document its always filtered on the last 5 years.

Regards

Andy

Re: How to create a filter for show only 5 year data instead of 20 year data ?

I would rather tend to create additionally selection-fields within the script maybe with something like this:

ceil((year(today() - year) / 5) as FiveYearsPeriod

or

class((year(today() - year), 5)

or other kind of flagging the data.

- Marcus

paulyeo11
Valued Contributor II

Re: How to create a filter for show only 5 year data instead of 20 year data ?

Hi All

Thank you very much for all of you sharing  , i will try out every approach.

Paul