Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
hobanwashburne
Creator
Creator

Master Calendar with offset

The Master Calendar below seems to work fairly well, but I need to add a Fiscal period which is a 3 month offset from the calendar month (Fiscal Period 201301 = Calendar month 201304 (April)) also our Quarters are also offset Q1 = April thru June. How would I modify the script?


let vMinDate = num(makedate(2006,1,1));
let vMaxDate = num(makedate(2013,12,31));
Let vCurDate = Num(Today());
let vToday = $(vCurDate);

TempCal:
LOAD
date($(vMinDate) + RowNo() - 1 ) as TempDate
AutoGenerate
$(vMaxDate)-$(vMinDate) + 1;

MasterCalendar:
LOAD
TempDate as Date,
Week(TempDate) as Week,
Year(TempDate) as Year,
Month(TempDate) as Month,
Day(TempDate) as Day,
WeekDay(TempDate) as WeekDay,
'Q' & Ceil(month(TempDate)/3) as Quarter,
Date(MonthStart(TempDate), 'MMM-YYYY') as MonthYear,
Week(TempDate)& '-' & year(TempDate) as WeekYear,
InYearToDate(TempDate, $(vToday), 0) * -1 as CurYTDFlag,
InYearToDate(TempDate, $(vToday), -1) * -1 as LastYTDFlag
Resident TempCal
Order By TempDate asc;
DROP Table TempCal;


Labels (1)
1 Solution

Accepted Solutions
Clever_Anjos
Support
Support

Date(addmonths(MonthStart(TempDate),-3), 'MMM-YYYY') as FiscalMonthYear,

'Q'&ceil(Month(addmonths(MonthStart(TempDate),-3))/3) as FiscalQuarter

View solution in original post

6 Replies
Clever_Anjos
Support
Support

Date(addmonths(MonthStart(TempDate),-3), 'MMM-YYYY') as FiscalMonthYear,

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Maybe this:

Date(MonthStart(TempDate,-3), 'YYYYMM') as FiscalPeriod,

'Q'&ceil(month(MonthStart(TempDate,-3))/3) as FiscalQuarter


talk is cheap, supply exceeds demand
hobanwashburne
Creator
Creator
Author

Any ideas on how to offset the quarters?

Clever_Anjos
Support
Support

Apply Gysbert formula to Date(addmonths(MonthStart(TempDate),-3), 'MMM-YYYY')

hobanwashburne
Creator
Creator
Author

I'm still missing something

Clipboard01.jpg

Clipboard02.jpg

Clever_Anjos
Support
Support

Date(addmonths(MonthStart(TempDate),-3), 'MMM-YYYY') as FiscalMonthYear,

'Q'&ceil(Month(addmonths(MonthStart(TempDate),-3))/3) as FiscalQuarter