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: 
ananyaghosh
Creator III
Creator III

How to calculate quarter based on datetime field ?

Hi,

I need to know how quarters in a year will be calculated based on current date time and also based on date field from my database.

If I have a field of type date and need to calculate Quarters (Suppose Q1, Q2, Q3 and Q4), then how to do that thing?

4 Replies
buzzy996
Master II
Master II

try tis in ur script Date/calendar table.

'Q' & Ceil(Month([Order Date])/3) As Quarterly,

ToniKautto
Employee
Employee

=Num(Ceil( Month(MyDate)/ 3 ), 'Q0')

manojkulkarni
Partner - Specialist II
Partner - Specialist II

use some thing like below as Mapping table :

QuartersMap: 

MAPPING LOAD  

rowno() as Month, 

'Q' & Ceil (rowno()/3) as Quarter 

AUTOGENERATE (12);

rajkumarb
Creator II
Creator II

HI Try This

QuartersMap: 

MAPPING LOAD  

rowno() as Month, 

'Q' & Ceil (rowno()/3) as Quarter 

AUTOGENERATE (12); 

MasterCalendar: 

Load 

               TempDate AS DATE, 

               week(TempDate) As Week, 

               Year(TempDate) As Year, 

               Month(TempDate) As Month, 

               Day(TempDate) As Day, 

               date(monthstart(TempDate), 'MMM-YYYY') as MonthYear, 

               ApplyMap('QuartersMap', month(TempDate), Null()) as Quarter, 

               Year(TempDate) & ' ' & ApplyMap('QuartersMap', month(TempDate), Null()) as CalendarYearQuarter, 

               RIGHT(Year(TempDate) & ' ' & ApplyMap('QuartersMap', month(TempDate), Null()), 2) AS CalendarQuarter,

               Week(weekstart(TempDate)) & '-' & WeekYear(TempDate) as WeekYear, 

               WeekDay(TempDate) as WeekDay 

Resident TempCalendar 

Order By TempDate ASC; 

Drop Table TempCalendar;