Power Query Problems

Group Data and Keep Other Columns in Excel Power Query

Amos GikundaAmos Gikunda Dec 2, 2026 869 views

Question details

Group records in Power Query while preserving related columns or returning the original rows with maximum values.

Group Data and Keep Other Columns in Excel Power Query
Product
Microsoft Excel Power Query
Device & OS
not provided
Scenario
The user wants to calculate sums or maximums by selected keys and retain information from the source records.
Observed behavior
The desired result includes group calculations alongside relevant original columns.
Before you start

Open the query in Power Query Editor and identify the grouping keys, the numeric column to aggregate, and the columns you want to retain. Make sure matching key and value columns use compatible data types.

Solution 1Recommended

Merge grouped maximums with the original rows

Use this method to return the source columns for every record that matches its group's maximum value.

1
Preserve the original rows

In the Queries pane, right-click the query before grouping and select Duplicate. Keep one copy as the original-row query and use the other for grouping.

2
Calculate the maximum

Select the grouping copy, then choose Home > Group By. Select Advanced, add the required key columns, and create an aggregation with the Max operation on the value column.

3
Merge with the original query

Select the grouped query and choose Home > Merge Queries. Choose the original-row query as the second table, not the grouped query itself.

4
Match keys and maximum values

In the merge dialog, select the group keys and maximum column in the grouped table, then select the corresponding keys and value column in the original table in the same order. Use an Inner join and select OK.

5
Expand the matching rows

Select the expand icon on the merged column and choose the original columns you want to return. Select Home > Close & Load to load the result.

Merge grouped maximums with the original rows
Tied maximums: If multiple source rows share the maximum value within a group, the merge returns all of them.
Free Microsoft Office alternative

Work with grouped spreadsheet data in WPS Office

WPS Office is a free, lightweight Microsoft Office alternative with a familiar spreadsheet interface and support for common Excel formats, making it easy to move existing files. It does not fix Excel Power Query or replace the merge workflow described above.

Use familiar spreadsheet tools to sort and review grouped dataOpen and edit Microsoft Excel XLSX and XLS filesMove existing spreadsheets to a familiar, easy-to-use interfaceUse a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why do other columns disappear when I use Group By?

Group By returns the selected keys and aggregation results rather than every source column. Add an All Rows aggregation to retain nested source records, or merge the grouped results with the original query.

How do I return the row with the highest value in each group?

Use Home > Group By to calculate Max for each key, then use Home > Merge Queries to match the grouped keys and maximum value to the original query's keys and value column. Expand the merged column to return the source fields.

What happens if two rows have the same maximum value?

Both rows match the group maximum and are returned by the merge. Apply an additional tie-breaking rule if you need only one row per group.

Can I keep individual rows and show a group sum?

Yes. In Home > Group By, choose Advanced and add both a Sum aggregation and an All Rows aggregation. Expand All Rows to show the original records; the group sum will repeat for each record.