Power Query Problems

Group Excel Rows into One Row per Category

Phi Hung VoPhi Hung Vo Dec 2, 2026 869 views

Question details

Combine a two-column list into one row per category, with all associated values in a single cell.

How to Group Excel Rows into One Row per Category
Product
Microsoft Excel
Device & OS
not provided
Scenario
A list contains repeated categories such as X1 with related values such as Y1 and Y2.
Observed behavior
The desired output has one row for each category, such as X1 with Y1, Y2 and X2 with Y4.
Before you start

Give the two source columns headers, such as Category and Value, and check whether blank categories or duplicate values should appear in the output. The Power Query example below expects an Excel table named Table1 with those exact column headers.

Solution 1Recommended

Group and combine values with Power Query

Use Power Query when you want a grouped result that you can refresh after the source data changes.

1
Create a source table

Select the two-column list, choose Insert > Table, and confirm that the table has headers. On the Table Design tab, set the table name to Table1 and make sure its columns are named Category and Value.

2
Open Power Query

Click inside Table1 and choose Data > From Table/Range to open the table in Power Query Editor.

3
Add the grouping code

In Power Query Editor, choose Home > Advanced Editor. Replace the existing code with: let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], Grouped = Table.Group(Source, {"Category"}, {{"Values", each Text.Combine(List.Transform(List.RemoveNulls([Value]), each Text.From(_)), ", "), type text}}) in Grouped. Select Done.

4
Load the result

Choose Home > Close & Load to place the grouped Category and Values columns in a worksheet.

Group and combine values with Power Query
Refresh after changes: After editing or adding rows to Table1, select the query output and choose Data > Refresh All. The query skips null values but retains duplicate values.
Work with grouped data in WPS Spreadsheet

Combine category values in WPS Spreadsheet

For a small list, use WPS Spreadsheet to sort categories and concatenate their related values into a separate summary table.

  1. 1. Open the list: Open WPS Spreadsheet and choose Open to select your workbook. Make sure column A contains categories and column B contains their related values.
  2. 2. Sort the source rows: Select both columns, then use Data > Sort to sort by the category column. Keep each category and its value on the same row.
  3. 3. Create summary rows: In an empty column, enter each category once. In the adjacent column, combine its value cells with a formula; for example, enter =B2&", "&B3 for values in B2 and B3, or =B4 for a category with one value.
  4. 4. Save the workbook: Check the summary against the source rows, then choose File > Save As and select an Excel workbook format if you need to share it with Excel users.
Create one summary row per category using cell referencesOpen and edit Microsoft Excel XLSX filesSort related rows together before combining valuesUse a familiar spreadsheet interface
microsoft office alternative - wps office

Frequently Asked Questions

How do I update the Power Query result when I add rows?

Add the new rows to the source Excel table, then choose Data > Refresh All. Power Query will regenerate the grouped output.

Will the grouped output remove duplicate values?

No. Both the provided Power Query code and the TEXTJOIN formula retain duplicates. Remove duplicates from the source or modify the query if each value should appear only once.

Why does the formula return a function error?

Check whether your Excel version supports UNIQUE and FILTER, and verify that the formula uses the correct cell ranges. If those functions are unavailable, use the Power Query method instead.

Can I change the separator between combined values?

Yes. In the Power Query code, replace the comma-and-space delimiter in Text.Combine. In the formula, replace the first argument of TEXTJOIN with your preferred separator.