Thank you for your reply.
I checked the document and this applies the 12 months to 1 chart.
I would need a button and when this button is active it needs to select the last 12 months.
When no year(and month) is selected it takes from today otherwise the last 12 months from that date.
I created the flag Rolling12MthFlag like described in the document. But then I still don't know how to setup my button.
=if(v12M = 1, '>=' & date(AddYears(Now(),-1)) & '<= ' & date(now()), )
I know the Now() needs to be replaced by something but I can't figure out what.
thank you for your help.
Indeed I didn't came up with that I was still doing my selection on the date field.
but still I'm missing something. If I add table with the dates and Rolling12MthFlag.
I see a status 1 for every date that is in the last 12 months. But when I select a year the flag is not recalculated.
Will a script recalculate the flag when you make a selection?
I would give you the document but
This is the Script for the calendar I have.
min(RejectionDate) as MinDate,
max(RejectionDate) as MaxDate
Resident RejectionHeaders ;
LET varMinDate = num(Peek('MinDate', 0, 'Temp_Dates'));
LET varMaxDate = num(Peek('MaxDate', 0, 'Temp_Dates'));//makedate(Year(Peek('Datum', -1, 'Temp_Dates')),12,31)//num();
LET vToday = $(varMaxDate);
Drop table Temp_Dates;
//*************** Temporary Calendar ***************
$(varMinDate)+IterNo()-1 as Num,
Date($(varMinDate)+IterNo()-1) as TempDate
AUTOGENERATE 1 WHILE $(varMinDate)+IterNo()-1<= $(varMaxDate);
//*************** Master Calendar ******************
TempDate as RejectionDate,
Year(TempDate) as Year,
Month(TempDate) as Month,
Date(MonthStart(TempDate), 'MMM-YYYY') as MonthYear,
if(makedate(2000, Month(TempDate), Day(TempDate)) < makedate(2000, month(Today()),
'Year-to-date') as YTD,
Week(TempDate) as Week,
'Q' & Ceil(Month(TempDate)/3) as Quarter,
Weekstart(TempDate) as Weekstart,
Weekend(TempDate) as Weekend,
Day(TempDate) as Day,
if(TempDate>=monthstart(AddMonths($(vToday), -12)) AND TempDate<monthstart($(vToday)), 1, 0) as Rolling12MthFlag
ORDER BY TempDate Asc;
Drop table TempCalendar;
My button has
=if(v12M = 1,'= ' & 1 , )
The flag will only be calculated during reload,
If you want the previous year recalculated based on selected date, have a look at
"Working With Dates" tab on the same "Qlikview How To" document.
You can go by having a Startdate and EndDate variables,
The Tutorial has made use of 2 Calendar objects to assigned values to the variables,
in your case you can have the EndDate and calculated the StartDate with the AddYears()
The Select in Field Action on Buttons still are in play.