Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Qlikuser09
Creator II
Creator II

Dynamic Filter to filter by last /previous years

=Year =Max(Year) works fine in filtering out max year

Qlikuser09_0-1721410403319.png

 

, but =Year =Max(Year) -1 or Year = {"$(=Max(Year) - 3)"} not filtering out anything giving me null values in Year filter

 

Qlikuser09_1-1721410470328.png

 

 

 

Labels (2)
1 Solution

Accepted Solutions
MatheusC
Specialist
Specialist

@Qlikuser09 

see it like this:

=FieldYear=$(=max(FieldYear))  -> current
=FieldYear=$(=max(FieldYear))-1  -> previous

or

 

=FieldYear=Year(Today()) -> currect
=FieldYear=Year(Today())-1 -> previous



- Matheus

Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!

View solution in original post

5 Replies
MatheusC
Specialist
Specialist

@Qlikuser09 

see it like this:

=FieldYear=$(=max(FieldYear))  -> current
=FieldYear=$(=max(FieldYear))-1  -> previous

or

 

=FieldYear=Year(Today()) -> currect
=FieldYear=Year(Today())-1 -> previous



- Matheus

Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!
Qlikuser09
Creator II
Creator II
Author

thanks, the above formula (Year=Year(Today())-1)worked well for previous year to filter by . but i have data like below i wanted to filter by last three days or from current calendar date at midnight. what formula can be used in this case to filter by 

{< DateField= {"=DateField>= Date(Today() - 2) and Datefield<= Date(Today())"} >}  or 

=[Datefield]<=$(=max(DateField))-1  is not working and rendering any results 

 

Qlikuser09_0-1721418135000.png

 

MatheusC
Specialist
Specialist

Cool, try this

=FieldDate>=today()-2 and FieldDate<today() -> Does not include today's date

=FieldDate>=today()-2 and FieldDate<=today() -> includes today's date


- Matheus

Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!
Qlikuser09
Creator II
Creator II
Author

currently the "field Date" is not in the date format , is there way we could filter by the latest 3 dates without having to change the data model. (it works with only when filtered by year , but not with date or month)

MatheusC
Specialist
Specialist

If you can incorporate it into the script by creating a new field, that would certainly be the best way. However, you can also insert this formatting into your search filter

=Date(Floor(TimeStamp#(FieldDateTime, 'DD/MM/YYYY hh:mm:ss TT')), 'DD/MM/YYYY')

Regards

Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!