Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for
Did you mean:
Contributor III

## Make a button to select the date range of the previous year

Hello.

How can I make a button to select the date range of the previous year. Everything I've tried so far fails.

=Year(max([fecha]))-1

=(max({<[fecha.autoCalendar.Year]={"\$(=Year(max([fecha])))"}>}[fecha]))-1

Thank you!

Labels (1)
• ### General Question

1 Solution

Accepted Solutions
Specialist

see with the following expression, put your date field

`Concat({<[fecha]= {">=\$(=Date(YearStart(max([fecha]),-1),'DD/MM/YYYY'))<=\$(=Date(Yearend(max([fecha]),- 1),'DD/MM/YYYY'))"}>} DISTINCT date([fecha]), ';' )`

Regarts,
Matheus

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

Hi, @Magogar

try to adjust like:

max([fecha])-1

or

year(today())-1

Regarts,
Matheus

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

Thanks, but it doesn't work. The dates are in DD/MM/YYYY format, and I want to get the date range of the previous entire year. For the buttons I don't know how to write it.

=Year(max([fecha]))-1

=max(year([fecha.autoCalendar.Year]))-1

=max(year([fecha.autoCalendar.Year])-1)

=max([fecha.autoCalendar.Year])-1

Specialist

see with the following expression, put your date field

`Concat({<[fecha]= {">=\$(=Date(YearStart(max([fecha]),-1),'DD/MM/YYYY'))<=\$(=Date(Yearend(max([fecha]),- 1),'DD/MM/YYYY'))"}>} DISTINCT date([fecha]), ';' )`

Regarts,
Matheus

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

Awesome! it works perfectly. Thanks a lot.