Calculate Nested Table Values Without Expanding in Excel Power Query
Question details
Calculate a value from each nested table created by a merge without expanding the nested rows.

- Product
- Microsoft Excel Power Query
- Device & OS
- not provided
- Scenario
- A merged query contains a column of nested tables, and the user wants a sum or row count for each main-query row.
- Observed behavior
- Each nested table can be summarized in a custom column while keeping the main query at its existing row level.
Open the merged query in Power Query Editor and identify the nested-table column and the field you want to calculate. Confirm that the field contains numeric values if you plan to sum it.
Add a Custom Column to Summarize Each Nested Table
Use an M expression to calculate a sum or row count without expanding the merged results.
In Excel, open Data > Queries & Connections, then double-click the merged query to open Power Query Editor.
Select Add Column > Custom Column and enter a name such as Total.
In the custom column formula box, enter List.Sum([MergedTable][Amount]). Replace MergedTable with the nested-table column name and Amount with the numeric field name, then select OK.
Select the new Total column and choose an appropriate numeric type from Transform > Data Type.
If you no longer need the nested tables, right-click the MergedTable column header and select Remove. Select Home > Close & Load when finished.

Work with Spreadsheet Results in WPS Office
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface. Open compatible Excel files and continue working with their spreadsheet data; use Excel Power Query for the nested-table calculation and query refresh.

Frequently Asked Questions
How do I count matching rows without expanding the merged column?
In Power Query Editor, select Add Column > Custom Column and enter Table.RowCount([MergedTable]), replacing MergedTable with your nested-table column name.
Why does my sum formula return an error?
Check that the names in List.Sum([MergedTable][Amount]) match the nested-table column and its field, and that the field contains numeric values. Inspect the error in Power Query Editor for more detail.
Can I remove the nested-table column after calculating the total?
Yes. After adding the custom column, right-click the nested-table column header and select Remove. The calculation remains based on the earlier query step.
Will this calculation add rows to my main query?
No. The custom column returns one summary value for each existing main-query row, rather than expanding each nested table into multiple rows.




