Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Power Query Quarter from Date: Step-by-Step Guide

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To get the quarter from a date in Power Query, add a custom column with the formula Date.QuarterOfYear([YourDateColumn]). That returns a number from 1 to 4. If you want a label like "Q1" or "Q1 2024", wrap it with "Q" & Text.From(Date.QuarterOfYear([YourDateColumn])) or include the year. The steps below walk through the exact clicks in the Power Query Editor, plus the common pitfalls and fixes.

What You'll Need

  • Power BI Desktop, Excel with Power Query (Data > Get & Transform Data), or another host that includes the Power Query Editor.
  • A table or query that already contains a column of true date values (not text that looks like a date).
  • Basic familiarity with adding a custom column. No coding experience required.

Step-by-Step

  1. Load your data into Power Query. In Excel, select your table and go to Data > From Table/Range. In Power BI Desktop, use Home > Transform data to open the Power Query Editor. Confirm the date column is typed as Date (the icon next to the column header shows a calendar, not ABC). If it shows ABC, select the column, then Transform > Data Type > Date.
  2. Add a custom column. On the Home tab, click Custom Column. In the dialog, give it a name such as "Quarter".
  3. Enter the quarter formula. In the formula box, type , replacing with the exact name of your date column (including brackets). Click OK. A new column appears with values 1, 2, 3, or 4.
  4. Optional: make a text label. If you prefer "Q1" style, add another custom column with . For a year-quarter label like "2024-Q1", use .
  5. Set the data type. For the numeric quarter column, click the icon left of the new column header and choose Whole Number. For text labels, choose Text. This prevents sorting and aggregation issues later.
  6. Rename and reorder if needed. Double-click the column header to rename it. Drag it to the position you want.
  7. Apply and close. Click Home > Close & Load (Excel) or Home > Close & Apply (Power BI). The new column is now available in your data model or worksheet.

Menu labels can differ slightly by version, device, or region, but the Custom Column command is on the Home tab in all current versions of the Power Query Editor.

Common Mistakes

  • Using a text column as the date. If the column is typed as Text, Date.QuarterOfYear returns an error. Change the data type to Date first, and check for locale issues (for example, day/month order) if conversion fails.
  • Forgetting the square brackets. Column references in Power Query must be written as [ColumnName]. Without brackets, the formula is invalid.
  • Using Excel cell references. Power Query formulas do not use A2 or B2. Always use the column name in brackets.
  • Leaving the quarter as text when you need to sort. A text "Q1" sorts alphabetically; "Q10" would sort before "Q2" if you had more than four quarters, but with only Q1–Q4 it is fine. For numeric analysis, keep a whole-number quarter column.
  • Expecting the quarter to appear automatically. Power Query does not have a one-click "Quarter" button on the ribbon in all versions. The custom column is the reliable method.

Tips

  • Use Date.QuarterOfYear rather than dividing the month by 3 manually; it handles all date edge cases correctly.
  • If you need the quarter start date, use in a custom column and set the type to Date.
  • For fiscal quarters that do not start in January, calculate the month offset first. For example, a fiscal year starting in April: shifts the quarter boundaries by three months. Adjust the offset to match your fiscal calendar.
  • Name your columns clearly ("Quarter Number" vs "Quarter Label") so report users are not confused.
  • If you add the column in Power Query, it refreshes automatically when the source data changes; no manual rework is needed.

Troubleshooting

If the new column shows Error in every row, the date column likely contains blank values or text that cannot be converted. Filter out nulls or fix the source data, then refresh. If only some rows error, inspect those rows for invalid dates such as "31/02/2024" or stray spaces.

If the formula bar rejects your column name, check for typos and ensure the name is wrapped in square brackets exactly as it appears in the header. Column names are case-sensitive in some contexts; copy the name from the header to be safe.

If the quarter numbers look wrong, verify that your date column is not being interpreted with the wrong locale (for example, month and day swapped). In Power Query, you can change the locale for a column under Transform > Data Type > Using Locale.

If the Custom Column button is greyed out, make sure you have a query selected and are not in the middle of editing a step that blocks adding columns. Close any open dialog and try again.

If you do not see the new column after Close & Load, check that you added it to the correct query and that the query was not grouped or filtered in a way that hides it. In Excel, the results load to a new worksheet or the Data Model depending on your load settings.

Frequently Asked Questions

Can I get the quarter name ("Q1") directly without a custom column?

Not with a single built-in button in all versions. The custom column method is the standard approach. You can also use the Add Column > Date > Quarter of Year option if your version includes it, but the formula is more portable.

Does this work in Excel Power Query as well as Power BI?

Yes. The Power Query Editor is the same engine in both, so the formula and steps are identical. Menu locations may vary slightly.

How do I get the quarter for a fiscal year that starts in July?

Shift the date by the number of months between your fiscal start and January, then apply Date.QuarterOfYear . For a July start, subtract 6 months: . Adjust the offset to your fiscal calendar.

Why does my quarter column show 1, 2, 3, 4 instead of Q1, Q2?

Date.QuarterOfYear returns a number. To display "Q1", use the text concatenation formula in step 4, or format the column as text with a custom format if your host supports it.

Can I use this on a column that contains nulls?

Nulls will produce errors. Filter them out or replace them with a default date before adding the quarter column. Alternatively, wrap the formula in try ... otherwise null to handle errors gracefully.

Will the quarter update when new data is added?

Yes, as long as the query refreshes. The custom column is recalculated on every refresh, so new rows get the correct quarter automatically.