Master Calendar Scripts All Time :)
Quarter_Map:
Mapping
LOAD * INLINE [
Month, Quarter
Jan, Q4
Feb, Q4
Mar, Q4
Apr, Q1
May, Q1
Jun, Q1
Jul, Q2
Aug, Q2
Sep, Q2
Oct, Q3
Nov, Q3
Dec, Q3
];
Mapping
LOAD * INLINE [
Month, Quarter
Jan, Q4
Feb, Q4
Mar, Q4
Apr, Q1
May, Q1
Jun, Q1
Jul, Q2
Aug, Q2
Sep, Q2
Oct, Q3
Nov, Q3
Dec, Q3
];
///////////////////////////////////////
SET vDateMin =
Num(date('01/01/1950','DD/MM/YYYY'));
SET vDateMax = Num(date('31/12/2050','DD/MM/YYYY'));
LET vDateToday = Num(Today());
SET vDateMax = Num(date('31/12/2050','DD/MM/YYYY'));
LET vDateToday = Num(Today());
//LET vDateMin = Num(Peek('Open_DateTime',
0, 'Interval_Table'));
//LET vDateMax = Num(Peek('Close_DateTime', -1, 'Interval_Table'));
//LET vDateToday = Num(Today());
TempCalendar1:
LOAD
$(vDateMin) + RowNo() - 1 AS Date_Key,
Date($(vDateMin) + RowNo() - 1) AS Date
AUTOGENERATE 1
WHILE $(vDateMin)+IterNo()-1<= $(vDateMax);
Master_Calendar:
load Date_Key
,Date
,Date as CalendarDate
,Day(Date) as CalendarDay
,Week(Date) as CalendarWeek
,WeekName(Date) as CalendarWeekName
,month(Date) as CalendarMonth
,MonthName(Date) as CalendarMonthName
,MonthName(Date) as CalendarPeriod
,Quartername(Date) as CalendarQuarterName
,ApplyMap('Quarter_Map',num#(month(Date)))as CalendarQuarter
,year(Date) as CalendarYear
,WeekDay(Date) as CalendarWeekDay
,text(weekday(Date)) as Week_Day1
,WeekDay(Date) as CalWeekDay
,Week(Date) as CalWeek
,week(Date+3) as CalRWeek
,WeekName(Date) as CalWeekName
,WeekName(Date,1,4) as CalWeekRName //4=Fri // Friday - Thursday Business Week
,MakeWeekDate(Year(Date),Week(Date)) as CalWkSD
,num(MakeWeekDate(Year(Date),Week(Date))) as CalWkSDNum
,MakeWeekDate(Year(Date+3),Week(Date+3),-3) as CalWkRSD
,num(MakeWeekDate(Year(Date+3),Week(Date+3),-3)) as CalWkRSDNum
Resident TempCalendar1;
DROP Table TempCalendar1;
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
LET vMinDate = Num(MakeDate(2014,1,1)); // Calendar Start Date
LET vMaxDate = Num(Today()); // Calendar End Date
LET vDays = vMaxDate - vMinDate + 2; // Calculating number of days between Start & End Dates
Calendar:
LOAD Date(Floor(TimeStamp)) AS Date,
TimeStamp,
Hour(TimeStamp) AS Hour,
Minute(TimeStamp) AS Minute;
LOAD
Timestamp($(vMinDate) + (RecNo() - 1)/48) as TimeStamp
AUTOGENERATE 48 * $(vDays);
//LET vDateMax = Num(Peek('Close_DateTime', -1, 'Interval_Table'));
//LET vDateToday = Num(Today());
TempCalendar1:
LOAD
$(vDateMin) + RowNo() - 1 AS Date_Key,
Date($(vDateMin) + RowNo() - 1) AS Date
AUTOGENERATE 1
WHILE $(vDateMin)+IterNo()-1<= $(vDateMax);
Master_Calendar:
load Date_Key
,Date
,Date as CalendarDate
,Day(Date) as CalendarDay
,Week(Date) as CalendarWeek
,WeekName(Date) as CalendarWeekName
,month(Date) as CalendarMonth
,MonthName(Date) as CalendarMonthName
,MonthName(Date) as CalendarPeriod
,Quartername(Date) as CalendarQuarterName
,ApplyMap('Quarter_Map',num#(month(Date)))as CalendarQuarter
,year(Date) as CalendarYear
,WeekDay(Date) as CalendarWeekDay
,text(weekday(Date)) as Week_Day1
,WeekDay(Date) as CalWeekDay
,Week(Date) as CalWeek
,week(Date+3) as CalRWeek
,WeekName(Date) as CalWeekName
,WeekName(Date,1,4) as CalWeekRName //4=Fri // Friday - Thursday Business Week
,MakeWeekDate(Year(Date),Week(Date)) as CalWkSD
,num(MakeWeekDate(Year(Date),Week(Date))) as CalWkSDNum
,MakeWeekDate(Year(Date+3),Week(Date+3),-3) as CalWkRSD
,num(MakeWeekDate(Year(Date+3),Week(Date+3),-3)) as CalWkRSDNum
Resident TempCalendar1;
DROP Table TempCalendar1;
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Thx for the QlikCommunity Post : by Jagan Mohan
https://community.qlik.com/docs/DOC-9146
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
"Master Calendar with every 30 Minutes"
LET vMinDate = Num(MakeDate(2014,1,1)); // Calendar Start Date
LET vMaxDate = Num(Today()); // Calendar End Date
LET vDays = vMaxDate - vMinDate + 2; // Calculating number of days between Start & End Dates
Calendar:
LOAD Date(Floor(TimeStamp)) AS Date,
TimeStamp,
Hour(TimeStamp) AS Hour,
Minute(TimeStamp) AS Minute;
LOAD
Timestamp($(vMinDate) + (RecNo() - 1)/48) as TimeStamp
AUTOGENERATE 48 * $(vDays);