Grouping Tables (to show row detail)
This page shows how to group a table and still show some of the detail from the rows behind each total, which a standard PivotTable cannot do.
What a PivotTable leaves out
Section titled “What a PivotTable leaves out”A PivotTable is good at summarising. It adds up a numeric field, and it counts a text field.
The Excel table below has both kinds of field. Each row records a sale of cars of one make, with its group, its colour and the quantity sold:

A PivotTable summarises it by Group and Item, with the quantities summed:

Double-clicking the value for VW opens a new sheet with the row detail behind its quantity of 5, which turns out to be two rows:

That detail stays on the drill-down sheet, though. The PivotTable itself cannot list VW’s colours, Orange and Grey, beside its total. Power Query can, as the steps below show.
1. Group by Item and Group
Section titled “1. Group by Item and Group”Create a new query from the source table:
- Click anywhere in the table.
- On Excel’s Data tab, click From Table/Range.
In the Power Query editor:
- Remove the Date column.
- Select the Item and Group columns, holding Shift to select both, and click Group By on the Transform tab.
- Set up the dialog as below, with Qty summed into a Qty column and a second output, ColorList, using the All Rows operation.

The result has one row per make, and the ColorList column holds a Table object in each row:

2. Add a custom column for the row detail
Section titled “2. Add a custom column for the row detail”Add a custom column named ColorList2, with this formula:

Reading the formula from the inside out, it works through these steps for each row:
Table.Columntakes the Color column from the row’s table as a list.Table.FromListturns that list into a one-column table.Table.Distinctremoves the duplicate colours from the table.Table.Transposeturns the column into a single row, so that each colour sits in its own column.Table.ToListturns the row back into a list, andCombiner.CombineTextByDelimiterjoins the colours into one piece of text, separated by a comma and a space.
The new column holds a List object in each row. Selecting one shows its contents below the grid, such as Red, Yellow for Porsche:

Click the expand icon in the ColorList2 header and choose Expand to New Rows. Each list holds a single piece of text, so the column now shows the colours for each make in place of the lists.

Reorder and rename the columns, delete the ones that are no longer needed, and use Close & Load To to load the query to a worksheet.
The Power Query table has the same totals as the PivotTable, and it also lists the colours behind each one:
