Smart Systems for Home

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

Power Query Date.StartOfMonth: Step-by-Step Guide

· 6 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

Date.StartOfMonth takes a date, datetime or datetimezone value and returns the first day of that same month, at midnight. It is the fastest way to normalize transaction dates, invoice dates or event dates into monthly buckets for grouping, joining or building a calendar table in Power Query, and it is a single built-in function, so no add-ins or extra queries are required. You do need a valid date column that Power Query recognizes as a Date or DateTime type; if the column is still Text, the function throws an error until you convert it.

What You'll Need

  • Power Query available in Excel (Data tab, Get Data) or Power BI Desktop (Transform data / Home, Transform data). Exact menu labels can differ slightly by version, device and region.
  • A table or query already loaded with a date column that is typed as Date, DateTime or DateTimeZone.
  • Column names spelled exactly as they appear, since the M formula language is case-sensitive for field names in step references.

Step-by-Step

  1. Load your data into Power Query. In Excel choose Data, then Get Data, and point it at your source; in Power BI choose Home, then Transform data to open the editor. Either way you land in the Power Query Editor window.
  2. Find the date column in the data preview and check its type icon in the column header. If it shows ABC (text), click the icon and choose Date. The function requires a real date type; text dates will fail.
  3. Add a custom column: on the Home tab click Custom Column. In the dialog, give it a name such as Month Start, then in the formula box type = Date.StartOfMonth([OrderDate]), replacing OrderDate with your actual column name. Field references look like [ColumnName] and are case-sensitive.
  4. Click OK. A new column appears with the first day of the month for every row. Click the type icon on that new column header and set it to Date so sorting and grouping treat it correctly.
  5. Optionally use the head of the function as the column value directly. In the Add Column tab, Date, then Month, then Start of Month does the same thing through the interface without writing a formula. It is handy when you would rather avoid code.
  6. Group on the result. Use Transform, then Group By, and group on your new Month Start column, choosing an aggregation such as Sum of Amount. This collapses every transaction into one row per month.
  7. Rename the step if you like: right-click the step in the Applied Steps pane on the right and choose Rename. Clear step names help when you revisit the query later.
  8. Close and load with Home, then Close & Load. The monthly table lands in a worksheet or the data model in Excel, or in the Power BI model, where you can build a visual on it.

Worked example. Suppose a Sales table has an OrderDate column typed as Date, with a row for 2026-03-17. Date.StartOfMonth([OrderDate]) returns 2026-03-01 00:00:00. Group By on that column with Sum of Amount gives March sales as one figure. Every row in March maps to 2026-03-01, every row in April to 2026-04-01, and so on, which is exactly the shape a chart axis wants.

Related variants worth knowing. Date.EndOfMonth returns the last day of the month, which is useful for reporting cutoffs. Date.StartOfWeek and Date.StartOfYear follow the same pattern for other periods. If your dates live in a DateTime column, a Text.From comparison or a merge on month number will be far slower and error-prone than normalizing with Date.StartOfMonth first.

Common Mistakes

  • Text instead of dates. This is the most frequent failure. The function throws "We cannot convert the value to type Date" when the column is Text. Convert the column type before calling the function.
  • Wrong bracket syntax. M references columns in square brackets with the exact name. Writing [orderdate] when the column is called OrderDate does not match.
  • Confusing Date.StartOfMonth with DateTime functions. Passing a text string like "3/17/2026" fails; the value must already be a date or datetime.
  • Forgetting the new column's type. If you leave the result as Any, group by or merge steps can behave unpredictably. Set the type to Date.
  • Using a non-existent month column. Some users expect a month name output. Date.StartOfMonth returns a date, not a month label. If you need "March 2026", combine it with Date.ToText, for example Date.ToText(Date.StartOfMonth([OrderDate]), "MMMM yyyy").
  • Timezone surprises. For DateTimeZone values, the result respects the value's timezone offset. If you need a clean date, wrap the input with DateTime.Date first.

Tips

  • Build a calendar or month table once: a query listing every month start for a range, then relate your fact table to it in the data model. That avoids repeating the formula in many queries.
  • Use the ribbon commands (Add Column, Date, Month, Start of Month) when you are learning the function; the editor writes the same M code for you, which is a good way to see correct syntax.
  • Put the type change on the same step as the custom column where possible. Fewer steps make the Applied Steps pane easier to read and troubleshoot.
  • When comparing months across years, use both StartOfMonth and StartOfYear, or add a Year column, so January of one year does not mix with January of another in a visual.
  • Test on a small sample first. Duplicate the query, keep a handful of rows, and confirm the output across a year boundary before applying it to a large dataset.

Troubleshooting

"Expression.Error: The field 'X' of the record wasn't found." The column name in brackets does not match. Select the step before the custom column and read the exact header spelling, including spaces.

"We cannot convert the value null to type Date." At least one row has an empty date. Add a step that replaces nulls or filters them out before the function. You can also wrap the call conditionally: if [OrderDate] = null then null else Date.StartOfMonth([OrderDate]).

Dates show as numbers. That is Excel's serial date storage showing through. Set the column type to Date in Power Query, and format the loaded output column as a date in the worksheet if needed.

The function is not available. Date.StartOfMonth is a standard library function, so if it fails, the query is likely in a context where the value is not typed as date. Confirm the type on the step feeding the custom column.

If that did not work, close and reopen Power Query, or clear the query's loaded data and refresh. In Excel, Data, then Refresh All reloads the query; a stale cache can show old results after a type change. Reloading does not delete your query definition, so it is safe, but refreshing may take time on large sources.

Frequently Asked Questions

What exactly does Date.StartOfMonth return?

A date value set to the first day of the month at midnight, based on the input date. Given 2026-12-05 it returns 2026-12-01 00:00:00.

Does it work on DateTime columns?

Yes. The time portion is discarded and the value snaps to the first of the month. It works on Date, DateTime and DateTimeZone values.

How do I get the month name instead of a date?

Wrap it in Date.ToText with a format string such as "MMMM" for the name or "MMM yyyy" for a short label.

Can I use it without writing M code?

Yes. Add Column, then Date, then Month, then Start of Month performs the same conversion through the interface.

Why does my date column still error after using it?

The source column is almost certainly typed as Text or contains nulls. Change the type first and handle nulls before the function runs.

Does the result respect timezones?

For DateTimeZone input the timezone offset is preserved. To work with plain dates, convert with DateTime.Date first.