Power Query Problems

How to Sort Excel Records by Date Without Separating Related Rows

Olivia MillerOlivia Miller Nov 4, 2026 870 views

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.

Sort Excel Records by Date Without Separating Related Rows
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.
Before you start

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.

Solution 1Recommended

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.

1
Import data into Power Query

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.

2
Group by Person and Transaction

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.

3
Sort by Date

Click the dropdown arrow on the Date column header and select 'Sort Descending' so the most recent requests appear at the top.

4
Keep the latest request

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.

5
Expand and load the data

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.

Non-destructive Editing: Using Power Query does not alter your original data. All transformations are saved as a query, and the output is placed in a completely separate worksheet.
Manage Complex Data

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. 1. Open your dataset: Launch WPS Spreadsheet and open your Excel workbook containing the complex transaction data.
  2. 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. 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.
Intuitive multi-level sorting to keep related transaction rows groupedAdvanced filtering tools to quickly extract the latest recordsSeamlessly open, edit, and save Microsoft Excel (.xlsx) filesLightweight, fast performance for handling large datasets
QA img-9

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.