Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Aasir
Creator III
Creator III

Master Calendar Table

Below is a full script that you can use to create your Calendar table.

'DateKey' is the column from the next Table you can customize by just replacing it with yours or easy part is load your column name as 'DateKey'

MasterCalendar:
Load
TempDate AS DateKey,
week(TempDate) As Week,
Year(TempDate) As Year,
Month(TempDate) As Month,
Day(TempDate) As Day,
'Q' & ceil(month(TempDate) / 3) AS Quarter,
Week(weekstart(TempDate)) & '-' & WeekYear(TempDate) as WeekYear,
WeekDay(TempDate) as WeekDay,
if(Month(TempDate) >= 7, Year(TempDate) + 1, Year(TempDate)) as FY,
// Create a calculated field for the Month-Year combination
Left(Month(TempDate), 3) & '-' & Right(Year(TempDate), 2) as MonthYear,
// Create a calculated field for the Month-Year combination
Left(Month(TempDate), 3) & '-' & Right(if(Month(TempDate) >= 7, Year(TempDate) + 1, Year(TempDate)), 2) as MonthFY,
Date(TempDate) as SortDate
;

//=== Generate a temp table of dates ===
LOAD
date(mindate + IterNo()) AS TempDate
,maxdate // Used in InYearToDate() above, but not kept
WHILE mindate + IterNo() <= maxdate;

//=== Get min/max dates from Field ===/
LOAD
min(FieldValue('DateKey', recno()))-1 as mindate,
max(FieldValue('DateKey', recno())) as maxdate
AUTOGENERATE FieldValueCount('DateKey');

0 Replies