Power Query Merge Rows: How to Combine Data in Excel
In this article
Power Query merge rows combines multiple rows of similar data into a single row, reducing redundancy and improving data clarity—essential for cleaning survey responses, transaction logs, or grouped records. Before you begin, ensure your data is in an Excel table or loaded into Power Query, and that the columns you want to merge have consistent headers and data types.
What You'll Need
- Microsoft Excel 2016 or later (including Microsoft 365)
- A dataset loaded into Power Query Editor
- At least two rows with matching key values to group
- Access to the Power Query Editor (Data > Get & Transform > From Table/Range)
Step-by-Step
- Open your Excel workbook and select the range of data you want to merge. Press Ctrl+T to convert it into a table if it isn’t one already.
- Go to the Data tab and click Get & Transform > From Table/Range. This opens the Power Query Editor.
- In the Power Query Editor, identify the column(s) that define the group you want to merge by—this is your key column, such as Customer ID, Order Number, or Project Code.
- Select the key column(s) by clicking their headers. Hold Ctrl to select multiple columns if merging across multiple criteria.
- Go to the Transform tab and click Group By.
- In the Group By dialog box, leave the Group By field set to your selected key column(s). For the New column name, type a name like MergedData. For Operation, choose All Rows. Click OK.
- A new column will appear titled MergedData containing tables for each group. Click the double-arrow icon (Expand) in the column header of MergedData.
- In the Expand dialog, check all columns you want to include from the nested tables. Under Aggregation, select Don’t Aggregate—this preserves all original values instead of summing or averaging.
- Click OK. You now see all rows for each group expanded side-by-side, but still as separate rows.
- To merge values within a single cell, select the column you want to combine, such as Notes or Products. Go to the Transform tab, click Group By again.
- This time, group by your original key column(s) only. For New column name, type something like CombinedNotes. For Operation, choose Concatenate. For Separator, enter a comma and space (, ) or another delimiter like | or ;. Click OK.
- Remove any temporary or duplicate columns you no longer need by right-clicking the column header and selecting Remove.
- Click Close & Load to return the merged data to Excel.
Common Mistakes
- Trying to merge rows without a unique key column—Power Query needs at least one column to group by, or it will treat every row as unique.
- Using Sum or Average instead of Concatenate when combining text values, which results in errors or zeros.
- Forgetting to uncheck Use original column name as prefix in the Expand dialog, creating confusing column names like MergedData.Product instead of Product.
- Not selecting All Rows in the first Group By step, which prevents access to nested tables needed for concatenation.
- Merging columns with mixed data types (text and numbers) without converting them first—use Change Type to set all to Text before concatenating.
Tips
- Use a pipe (|) or semicolon (;) as a separator instead of a comma if your data contains commas, to avoid parsing issues later.
- Before merging, sort your data by the key column to ensure consistent ordering in the final output.
- Test on a small subset of data first—copy a few rows to a new sheet and apply the steps there to verify results before running on your full dataset.
- Use View > Advanced Editor to inspect the M code generated; look for
Table.GroupandText.Combinefunctions to understand what’s happening under the hood. - Save your workbook before running merge operations—Power Query transformations are reversible, but it’s safer to have a backup.
- If you’re combining dates, convert them to text first using Change Type > Text to avoid formatting inconsistencies in the final string.
Troubleshooting
- If the Concatenate option doesn’t appear under Operation, your selected column likely contains non-text data. Convert it to Text using the Transform > Data Type > Text menu before retrying.
- If merged rows appear blank, check whether the source column contains only null or empty values. Use Replace Values to change nulls to empty strings if needed.
- If you see errors like Expression.Error: We cannot apply operator <> to types Text and Number, you’re trying to combine incompatible types. Use Text.From in the Advanced Editor or convert all values to text first.
- If the merged data doesn’t reflect all rows, ensure you selected All Rows in the first Group By step. If you chose Sum or Count, you lost the original row data.
- If Power Query crashes or freezes during merge, reduce the dataset size temporarily. Large tables (100k+ rows) may require more memory—close other apps or restart Excel.
- If the output doesn’t load back to Excel, check that you’re not overwriting a protected sheet or named range. Try loading to a new worksheet by clicking Close & Load To and selecting New worksheet.
Frequently Asked Questions
Can I merge rows with different column structures?
No. Power Query requires the same column names and structure across rows being merged. If columns differ, use Append Queries first to standardize the schema.
Why are some rows missing after merging?
Rows may disappear if the key column has blank or null values. Use Remove Rows > Remove Blank Rows on the key column before grouping.
Can I merge rows and keep only unique values?
Yes. After concatenating, use Split Column > By Delimiter to split the merged text, then use Remove Duplicates on the resulting column, then re-concatenate.
Does merging rows affect the original data in Excel?
No. Power Query creates a transformation layer. Your original Excel table remains untouched—you can refresh or undo the query at any time.
Can I merge rows across multiple Excel files?
Yes. Use Get Data > From Folder to combine files first, then apply the merge steps to the combined dataset.
Is there a limit to how many rows I can merge?
Power Query can handle millions of rows, but performance slows with very large datasets. Use filters to reduce input size before merging, or break into batches if needed.