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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Define Quarter?

I have the Date field by using this field how can I Define the Quarter , yearQrtr ?

Thanks

Madhu

Labels (1)
1 Solution

Accepted Solutions
sunny_talwar
MVP
MVP

7 Replies
sunny_talwar
MVP
MVP

May be this:

'Q' & Ceil(Month(DateField)/3) as Quarter,

Year(Date) & 'Q' & Ceil(Month(DateField)/3) as YearQuarter

or you can also try this for YearQuarter:

Dual(Year(Date) & 'Q' & Ceil(Month(DateField)/3), Num#(Year(Date) & Ceil(Month(DateField)/3), '##')) as YearQuarter

sunny_talwar
MVP
MVP

Capture.PNG

SreeniJD
Specialist
Specialist

You have to explicitly convert the date into quarters..

see below expression..

'Q' & ceil(Num(month([$(_datefield)]))/3) as [$(_prefix)Qtr]


Not applicable
Author

Q means naming convention  right.

What is the use of Ceil and why u r using the Ceil beforedate function.

Not applicable
Author

Try

'Q' & ceil(month(Date_field)/3) as yearQrtr


Pallav

Not applicable
Author

josna g,

In your script add the folowing line for your date field:

Year(<datefield>) & Ceil(Month(<datefield>)/3)          As YearQuarter

to show YearQuarter as 20151, 20152, etc..

Or with some formatting:

Year(<datefield>) & NUM(Ceil(Month(<datefield>)/3), '00')          As YearQuarter

to show YearQuarter as 201501, 201502, etc..

Marc

sunny_talwar
MVP
MVP

Ceil is just used for rounding up the Month/3. So if you have January (which is also month number 1), you will have Ceil(1/3) = Ceil(0.33333) = 1

Feb -> Ceil(2/3) = Ceil(0.66666) = 1 and so on

HTH

Best,

Sunny