Qlik Community

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Qlik Insider: SaaS capabilities for Data Integration and Analytics, May 25th! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Qlik1_User1
Creator III
Creator III

To show only Current, last and next year data

Hi All,

Field YEAR has values from 1990 to 2050
Need to create a  filter pane having values 2019,2020,2021.

Chart should should show by default 2020 data and user is allowed to select only 1 value at a time (i.e. either 2019,2020 or 2021).


Below is the expression

Count( DISTINCT id)

1 Solution

Accepted Solutions
Kushal_Chawda

Create a filter pan with below expression

=aggr(only({<Year = {">=$(=year(today())-1)<=$(=year(today())+1)"}>}Year),Year)

 

then create a variable  vYear at front end with below expression

=if(GetSelectedCount(Year)=0,year(today()),max(Year))

 

then you can use below expression in your chart to restrict it default to current year ..based on filter selection it will change.

Count( DISTINCT {$<Year={"$(vYear)"}>}id)

View solution in original post

7 Replies
sunny_talwar

You want this dashboard wide or just for a chart?

MohasinKhan
Contributor III
Contributor III

Hi,

The simplest solution is can provide is to create a default bookmark.

Once you set it up, when anyone opens the app, by default 2020 would be selected.

Then you can create Year filter, so as and when anyone selects any year, data will change.

How to create Default bookmark:

  • Select the year 2020, so we have filter applied
  • On the upper right hand corner, click on Bookmark option beside edit button
  • Click create & give it a name
  • Right click on the Bookmark name and click "Set selections to app default"

This should do the trick.

If you want the default filter to change based on current year, you can create a dimension and then select latest year, something like this:

If ( [YEAR] = Date(today(),'YYYY') , 'Current Year' , 'Others')

Create Dimension using the above formula, select Current Year from results and set it as default bookmark.

This way, when we are in 2021, the year will automatically change to 2021.

About the filter:

You can simply write it as : if( [YEAR] > 2018, [YEAR] , null() )

And in the chart or table, un check show null values.

Hope this helps.

Qlik1_User1
Creator III
Creator III
Author

@sunny_talwar Just for a single chart

Qlik1_User1
Creator III
Creator III
Author

@MohasinKhan how to  create a filter pane having values 2019,2020,2021 only. 

sunny_talwar

Okay, so by default you have 2020, but then user should have the ability to select 2019 or 2021. But what happens if the user selects 2018 or 2022? Or would this never happen? If it will never happen, then why do you even bring the other years in the app? If it can happen, what will the dashboard show in that case?

Kushal_Chawda

Create a filter pan with below expression

=aggr(only({<Year = {">=$(=year(today())-1)<=$(=year(today())+1)"}>}Year),Year)

 

then create a variable  vYear at front end with below expression

=if(GetSelectedCount(Year)=0,year(today()),max(Year))

 

then you can use below expression in your chart to restrict it default to current year ..based on filter selection it will change.

Count( DISTINCT {$<Year={"$(vYear)"}>}id)
harneetma
Contributor
Contributor

I want to select by default 3 years in filter pane. Please help how to do that ?