Excel Power Query: How to Sort by Date Correctly
In this article
Yes, you can sort by date in Excel Power Query, and it takes just a few clicks: load your data into Power Query, click the filter arrow on the date column header, and choose Sort Ascending or Sort Descending. The one catch is that the column must actually be recognized as a Date type first; if Power Query treats your dates as text, sorting will be alphabetical rather than chronological (so "10/01" comes before "9/01"). This guide walks through the whole process, including how to fix the data type so the sort behaves properly.
These steps apply to Power Query in Excel for Microsoft 365 and Excel 2016 and later on Windows, where Power Query is built in. Menu labels can differ slightly by version, but the ribbon structure described below is the same in all recent versions.
What You'll Need
- Excel 2016 or later, or Microsoft 365, on Windows (Power Query is built in; Mac support is more limited)
- A table of data containing a date column
- Basic familiarity with Excel tables or ranges
Step-by-Step
- Convert your data to a table. Click any cell inside your data and press Ctrl + T, confirm the range in the dialog, and click OK. Power Query works best with Excel Tables.
- Load the table into Power Query. With a cell in the table selected, go to the Data tab on the ribbon and click From Table/Range. The Power Query Editor window opens.
- Check the date column's data type. Look at the icon on the left side of the column header. A small calendar icon means it is already a Date type. An ABC icon means Power Query thinks it is text and must be converted before sorting will work correctly.
- Fix the data type if needed. Right-click the column header, choose Change Type, then Date. If your dates are in a day/month/year format and Power Query misreads them, first go to Transform > Data Type > Using Locale, choose Date and the locale that matches your source (for example English (United Kingdom)), then click OK.
- Sort the column. Click the filter dropdown arrow on the date column header and choose Sort Ascending (oldest first) or Sort Descending (newest first). A small arrow appears on the column header showing the sort direction.
- Review the Applied Steps list. In the panel on the right, you should see a Changed Type step followed by a Sorted Rows step. Power Query applies steps top to bottom, so the sort always runs after the type conversion.
- Load the results back to Excel. On the Home tab of the Power Query Editor, click Close & Load (or Close & Load To to choose a destination sheet). The sorted data appears as a new table in your workbook.
- Refresh when the source changes. If you add rows to the source table, right-click anywhere in the query output and click Refresh, or use Data > Refresh All. Power Query re-applies all steps, including the sort, automatically.
Common Mistakes
- Sorting a text column. If the date column shows the ABC icon, the sort is alphabetical, not chronological. Always set the Date type first.
- Changing type after sorting. If you sort first and change the type afterwards, the sort step runs on text values. Drag the Changed Type step above the Sorted Rows step in the Applied Steps list, or delete the sort step and redo it after converting.
- Wrong locale interpretation. With day/month/year data, Power Query may swap day and month if the file's locale differs. Use Using Locale as described above rather than a plain type change.
- Mixed date formats in one column. If some rows are text like "Jan 5" and others are real dates, the type change will produce errors for some rows. Clean the source data first.
- Sorting inside the query and again in Excel. This is harmless but redundant; if you only need a sorted view without transforming data, sorting the worksheet table directly is simpler.
Tips
- Multi-level sorts: Power Query's dropdown only sorts one column at a time. For a two-level sort (for example by date, then by name), add two sort steps in reverse order: sort by the secondary column first, then by the primary column. Power Query sorts are stable, so the earlier order is preserved within ties.
- Sort direction icon: The up arrow means ascending, the down arrow means descending. Clicking the same sort option again reverses it.
- Delete a sort: To undo a sort permanently, click the Sorted Rows step in Applied Steps and press Delete, or click the X next to the step.
- Sort steps live in the query, not the sheet. Because the sort is part of the query, it survives every refresh, unlike a manual worksheet sort that can be lost when data reloads.
Troubleshooting
The sort is alphabetical, not by date. The column is being treated as text. Change the type to Date (step 4), then reapply the sort.
Dates show as errors after changing type. Some values don't match the expected format. Click Keep Errors or filter the column to see the problem rows, fix the source data, then refresh. If day and month are swapped, use Using Locale with the correct locale.
The Sort options are greyed out. This usually means the query is in a state where the column profile hasn't finished loading, or the query failed at an earlier step. Click Refresh Preview on the Home tab, and check the Applied Steps list for a step showing an error message.
The order changes after loading. You have a second step (such as a group or merge) after the sort that reorders rows. Move the Sorted Rows step to the bottom of Applied Steps by dragging it.
From Table/Range is missing. On Excel 2010 and 2013 you need the free Power Query add-in from Microsoft; it is built into Excel 2016 and later. On Mac, Power Query availability depends on your Excel version and data source, so check whether the Data tab shows Get Data (Power Query).
Frequently Asked Questions
Does sorting in Power Query change my original data?
No. Power Query never modifies the source. The sort applies only to the query output, which loads as a separate table.
Will the sort stick when I refresh?
Yes. The sort is a saved query step, so every refresh re-applies it in the same position in the step order.
Can I sort by date and time together?
Yes. Use the Date/Time type (rather than Date) so the time component is included in the sort order.
How do I sort by month name chronologically (Jan, Feb, Mar)?
Either add a numeric month column first (select the date column, then Add Column > Date > Month > Month) and sort by that, or sort by the underlying date column itself and display month names separately.
Why does my column show dates but still sorts wrongly?
It is almost certainly formatted to look like dates but stored as text. Check the icon in the column header and change the type as in step 4.
Can I sort within groups instead of sorting the whole table?
Yes. Use Transform > Group By with the operation set to All Rows, then sort each nested table, or sort the full table first and then group, since grouping preserves row order within each group.