Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Master Calendar

Hi, can anyone tell me where and when master calendar is used? Also state its advantages.

4 Replies
ashfaq_haseeb
Champion III
Champion III

Not applicable
Author

jpenuliar
Partner - Specialist III
Partner - Specialist III

its_anandrjs

Hi,

There is many reasons for this

1. You have Date field but rest of the date dimensions Year, Month, Quarter, YearStart, Day, Week etc are not available then you have to use the master calendar.

2. You have no proper Date formatted date field in the data model.

Example Code for the Master Calendar

LET vDateMin = Num(MakeDate(2014,04,05));

LET vDateMax = Floor(Today());

TempCalendar:

LOAD

date($(vDateMin)+IterNo()-1) AS Datefield,

date($(vDateMin)+IterNo()-1) AS TempDate

AUTOGENERATE (1)

WHILE $(vDateMin)+IterNo()-1<= $(vDateMax);

Calendar:

LOAD

Date(TempDate) AS ActionTime,

// Standard Date Objects

Day(TempDate) AS CalendarDayOfMonth,

WeekDay(TempDate) AS CalendarDayName,

Week(TempDate) AS CalendarWeekOfYear,

Month(TempDate) AS CalendarMonthName,

'Q' & Ceil(Month(TempDate)/3) AS CalendarQtr,

Year(TempDate) AS CalendarYr,

// Calendar Date Names

WeekName(TempDate) as CalendarWeekNumberAndYear,

MonthName(TempDate) as CalendarMonthAndYear,

QuarterName(TempDate) as CalendarQuarterMonthsAndYear

RESIDENT TempCalendar ORDER BY TempDate ASC;

DROP TABLE TempCalendar;

Regards

Anand