Group Excel Rows into One Row per Category
Question details
Combine a two-column list into one row per category, with all associated values in a single cell.

- 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.
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.
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.
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.
Click inside Table1 and choose Data > From Table/Range to open the table in Power Query Editor.
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.
Choose Home > Close & Load to place the grouped Category and Values columns in a worksheet.

Combine categories with dynamic array formulas
Use formulas when you have a compatible version of Excel and want the category list to update automatically.
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. 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. 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. 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. 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.

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.




