How to Sort Excel Records by Date Without Separating Related Rows
Question details
The user needs to sort an Excel dataset by date while keeping multiple related quote rows together for each transaction, and ultimately display only the latest request for each person.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Sorting complex datasets where multiple detailed rows (like individual quotes) belong to a single transaction or request, requiring the latest transaction per person to be filtered without breaking the transaction groups.
- Observed behavior
- Standard Excel sorting treats each row independently, separating related quote rows. The goal is to group the data by transaction, sort it by date to find the most recent request, and retain all associated quote rows.
Ensure your dataset is formatted as an Excel Table (Ctrl+T) and contains distinct columns for 'Person', 'Transaction ID', and 'Date' before importing it into Power Query.
Use Power Query to Group, Sort, and Filter Records
Leverage Excel's Get & Transform (Power Query) to group your data by person and transaction, ensuring related rows stay together during sorting.
Power Query is the most effective tool for this scenario because it allows you to package related rows into nested tables, sort the parent records, and then expand the rows back out without losing their association.
Select any cell inside your data table, navigate to the Data tab on the ribbon, and click 'From Table/Range' to open the Power Query Editor.
Select both the Person and Transaction ID columns. Go to the Home tab and click 'Group By'. In the dialog box, name the new column 'Details', set the Operation to 'All Rows', and click OK.
Click the dropdown arrow on the Date column header and select 'Sort Descending' so the most recent requests appear at the top.
To retain only the newest request per person, select the Person column, click 'Keep Rows' under the Home tab, and choose 'Keep Top Rows'. Alternatively, use the 'Group By' feature again to extract the MAX date per person.
Click the expand icon (two diverging arrows) on the header of the 'Details' column to reveal the related quote rows. Finally, click 'Close & Load' to output the sorted data to a new worksheet.
Use Helper Columns and Custom Sort
If you cannot use Power Query, you can achieve a similar result using formulas to identify the latest dates and multi-level sorting.
Sort and Organize Complex Datasets Easily in WPS Spreadsheet
WPS Spreadsheet offers powerful data sorting, multi-level filtering, and advanced pivot table capabilities, making it incredibly easy to manage transaction records and grouped quotes without losing data integrity.
- 1. Open your dataset: Launch WPS Spreadsheet and open your Excel workbook containing the complex transaction data.
- 2. Set up a multi-level sort: Highlight your data table, navigate to the Data tab, and click the Sort icon. Add levels to sort by Person, Transaction ID, and then Date.
- 3. Apply advanced filters: Use the Advanced Filter feature under the Data tab to isolate unique transaction groups or extract rows matching the most recent dates based on helper columns.

Frequently Asked Questions
Why do my related rows separate when I apply a date sort in Excel?
Standard sorting treats every row independently based entirely on the column you are sorting. To keep related rows (like quotes for a single transaction) together, they must be grouped logically using Power Query or sorted via a multi-level custom sort.
What is Power Query and where can I find it?
Power Query, also known as Get & Transform, is a data connection and preparation tool. In modern Excel versions, it is located on the Data tab under the 'Get & Transform Data' section (typically the 'From Table/Range' button).
Can I filter for the most recent transaction without using Power Query?
Yes. You can add a helper column utilizing the MAXIFS function to determine the latest transaction date for each person, and then apply a standard Excel filter to hide any rows that do not match that maximum date.
Does grouping data in Power Query delete the detailed rows?
No, grouping rows with the 'All Rows' operation simply compresses the detailed rows into a nested table. You can sort the grouped data and then click the expand icon on the grouped column header to restore all the original detailed rows.




