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: 
SkitzN27
Creator
Creator

Fiscal Year calculation using Master Calendar

Hi everyone,

Please find attached my script for the Master Calendar.  

It displays -

Jan- March- Q1

Apr-Jun- Q2

July-Sep- Q3

Oct-Dec- Q4

I want it to be displayed as 

Oct- Dec- Q1

Jan-Mar- Q2

Apr-Jun- Q3

Jul-Sep- Q4

What can I change in my script?

Here it is:

QuartersMap:
MAPPING LOAD
rowno() as Month,
'Q' & Ceil (rowno()/3) as Quarter
AUTOGENERATE (12);

Temp:
Load
min("Date") as minDate,
max("Date") as maxDate
Resident stocks;

Let varMinDate = Num(Peek('minDate', 0, 'Temp'));
Let varMaxDate = Num(Peek('maxDate', 0, 'Temp'));
DROP Table Temp;

TempCalendar:
LOAD
$(varMinDate) + Iterno()-1 As Num,
Date($(varMinDate) + IterNo() - 1) as TempDate
AutoGenerate 1 While $(varMinDate) + IterNo() -1 <= $(varMaxDate);

MasterCalendar:
Load
TempDate AS "Date",
week(TempDate) As Week,
Year(TempDate) As Year,
Month(TempDate) As Month,
Day(TempDate) As Day,
ApplyMap('QuartersMap', month(TempDate), Null()) as Quarter,
Week(weekstart(TempDate)) & '-' & WeekYear(TempDate) as WeekYear,
WeekDay(TempDate) as WeekDay
Resident TempCalendar
Order By TempDate ASC;
Drop Table TempCalendar;

 

Labels (1)
1 Solution

Accepted Solutions
SkitzN27
Creator
Creator
Author

I was ultimately able to solve it using the If conditions, but if in case anyone has a more optimized way to do it, please feel free to post it.
Thank you!

And here's my solution if anyone wants to refer:

'Q' & if(Ceil(Month(TempDate)/3)=1,2,if(Ceil(Month(TempDate)/3)=2,3,if(Ceil(Month(TempDate)/3)=3,4,if(Ceil(Month(TempDate)/3)=4,1)))) as FiscalQuarter,

View solution in original post

1 Reply
SkitzN27
Creator
Creator
Author

I was ultimately able to solve it using the If conditions, but if in case anyone has a more optimized way to do it, please feel free to post it.
Thank you!

And here's my solution if anyone wants to refer:

'Q' & if(Ceil(Month(TempDate)/3)=1,2,if(Ceil(Month(TempDate)/3)=2,3,if(Ceil(Month(TempDate)/3)=3,4,if(Ceil(Month(TempDate)/3)=4,1)))) as FiscalQuarter,