Date.QuarterOfYear
DateReturns the quarter of the year (1–4) for the given date.
Syntax
Date.QuarterOfYear(dateTime as any) as nullable numberParameters
| Name | Type | Required | Description |
|---|---|---|---|
dateTime | any | Yes | A date, datetime, or datetimezone value. |
Return Value
number — An integer from 1 to 4 representing the calendar quarter.
Remarks
Date.QuarterOfYear returns 1 for January–March, 2 for April–June, 3 for July–September, and 4 for October–December. It is equivalent to Number.RoundUp(Date.Month(d) / 3). If the input is null, the function returns null.
This function returns a simple integer (1–4) for use as a sort key or grouping column. To get the formatted quarter label (e.g., "Q1"), concatenate with text: "Q" & Text.From(Date.QuarterOfYear([OrderDate])). For the start or end date of a quarter, use Date.StartOfQuarter and Date.EndOfQuarter.
Note that Date.QuarterOfYear always uses standard calendar quarters. If your organization uses a non-standard fiscal calendar (e.g., fiscal year starting in April), you must calculate fiscal quarters manually based on the fiscal month offset.
Examples
Example 1: Add quarter number to the Sales table
Table.AddColumn(
Table.SelectColumns(
Table.FirstN(Sales, 5),
{"OrderID", "OrderDate"}
),
"Quarter", each Date.QuarterOfYear([OrderDate]), Int64.Type
)OrderID | OrderDate | Quarter | |
|---|---|---|---|
| 1 | 1 | 1/15/2024 | 1 |
| 2 | 2 | 1/18/2024 | 1 |
| 3 | 3 | 2/1/2024 | 1 |
| 4 | 4 | 2/10/2024 | 1 |
| 5 | 5 | 3/5/2024 | 1 |
Example 2: Show quarter number for the first month of each quarter
#table(
type table [Date = date, Quarter = number],
{
{#date(2024, 1, 1), Date.QuarterOfYear(#date(2024, 1, 1))},
{#date(2024, 4, 1), Date.QuarterOfYear(#date(2024, 4, 1))},
{#date(2024, 7, 1), Date.QuarterOfYear(#date(2024, 7, 1))},
{#date(2024, 10, 1), Date.QuarterOfYear(#date(2024, 10, 1))}
}
)Date | Quarter | |
|---|---|---|
| 1 | 1/1/2024 | 1 |
| 2 | 4/1/2024 | 2 |
| 3 | 7/1/2024 | 3 |
| 4 | 10/1/2024 | 4 |
Example 3: Add a formatted quarter label column
Table.AddColumn(
Table.SelectColumns(Table.FirstN(Sales, 5), {"OrderID", "OrderDate"}),
"QuarterLabel",
each "Q" & Text.From(Date.QuarterOfYear([OrderDate])) & " " & Text.From(Date.Year([OrderDate])),
type text
)OrderID | OrderDate | QuarterLabel | |
|---|---|---|---|
| 1 | 1 | 1/15/2024 | Q1 2024 |
| 2 | 2 | 1/18/2024 | Q1 2024 |
| 3 | 3 | 2/1/2024 | Q1 2024 |
| 4 | 4 | 2/10/2024 | Q1 2024 |
| 5 | 5 | 3/5/2024 | Q1 2024 |