Power Query M code
let
Source = YourTable,
AddedSortColumn = Table.AddColumn(Source, "MonthYearSort", each Date.ToText([DateColumn], "yyyy-MM"), type text)
in
AddedSortColumn
Adds a sortable text column combining year and month so month names sort chronologically instead of alphabetically.
let
Source = YourTable,
AddedSortColumn = Table.AddColumn(Source, "MonthYearSort", each Date.ToText([DateColumn], "yyyy-MM"), type text)
in
AddedSortColumn
Generate a date table in Power Query M
Use MonthYearSort as the 'Sort by column' for a MonthName or MonthYear label column in the model.
Browse all 145 snippets in the Power Query M Code Snippets, or search the library for something similar to Month-Year Sort Column (e.g., 2026-03).