Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Power Query Union: Combine Tables Step by Step

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Power Query Union combines multiple tables with identical or compatible columns into a single table, useful for consolidating data from similar sources like monthly sales reports or log files. No special setup is required beyond having Power Query enabled in Excel or Power BI, and at least two tables with matching column structures.

What You'll Need

  • Microsoft Excel 2016 or later, or Power BI Desktop
  • At least two tables with the same column names and compatible data types (e.g., text, number, date)
  • Power Query Editor accessible via the Data tab in Excel or the Transform Data button in Power BI

Step-by-Step

  1. Load all source tables into Power Query. In Excel, go to Data > Get Data > From Table/Range and select each table. In Power BI, use Get Data and choose the appropriate source (Excel, CSV, etc.) for each table. Each table will appear as a separate query in the Queries pane.
  2. Ensure all tables have identical column names and data types. Open each query in the Power Query Editor and verify column headers match exactly (including capitalization and spacing). If columns are misnamed, right-click the header and select Rename. If data types differ (e.g., one column is Text, another is Number), select the column and choose the correct type from the Transform tab > Data Type.
  3. Open the first table query you want to union. In the Power Query Editor, go to the Home tab and click Append Queries > Append Queries as New. This opens the Append dialog box.
  4. In the Append dialog, select "Two or more tables" from the dropdown. Then, check the box next to each additional query you want to include. You can hold Ctrl (or Cmd on Mac) to select multiple queries. Avoid selecting the same query twice.
  5. Click OK. Power Query creates a new query that combines all selected tables vertically, stacking rows from each source into one unified table. The new query appears in the Queries pane with a name like "Append1".
  6. Review the combined data. Scroll through the result to confirm rows from all sources are present and no unexpected duplicates or misalignments occurred. Use the filter arrows on column headers to check for anomalies in specific fields.
  7. Remove any temporary or unnecessary columns. If your source tables included metadata columns (like "SourceFile" or "Month") that you don’t need in the final output, right-click the column header and select Remove.
  8. Apply any additional transformations. Sort rows, filter out blanks, rename columns for clarity, or add calculated columns as needed. All steps will be recorded in the Applied Steps pane.
  9. Close and Load. Click Close & Load in the Home tab to push the final unioned table into Excel as a new worksheet, or into Power BI as a new dataset. The query will refresh automatically if source data changes.

Common Mistakes

  • Unioning tables with mismatched column names — Power Query will treat unmatched columns as nulls, creating data gaps. Always verify headers match exactly.
  • Including tables with incompatible data types — e.g., one table has dates as text, another as actual date values. This causes errors or incorrect sorting. Convert all to the same type before appending.
  • Appending too many tables at once — if you have 10+ tables, selecting them all in one Append step can cause performance issues. Union in smaller batches, then union the results.
  • Forgetting to remove duplicate column headers from source files — if a CSV file has a header row repeated within the data, Power Query may treat it as a data row. Use Remove Top Rows to eliminate extra headers before loading.
  • Not checking for hidden characters — extra spaces, non-breaking spaces, or tabs in column names can prevent matching. Use the Trim function (Transform > Format > Trim) on column headers if union fails unexpectedly.

Tips

  • Use the "Added Custom Column" feature before union to tag each row with its source table name (e.g., ="Sales_January"). This helps trace data origin after combining.
  • Sort your final table by date or ID after union to make analysis easier. Right-click any column header and choose Sort Ascending or Descending.
  • Save your workbook or Power BI file after each major step. Union operations can be resource-heavy; losing progress due to a crash is common with large datasets.
  • Use the Query Dependencies view (View > Query Dependencies) to visualize how tables feed into your union. This helps debug if a source table is missing or broken.
  • If unioning CSV files from a folder, use "Get Data > From Folder" instead of loading each manually. Power Query can automatically combine all files in the folder with consistent structure.
  • After union, right-click the query in the Queries pane and select Reference to create a backup copy. This lets you maintain the original unions while testing new filters or transformations.

Troubleshooting

  • If the Append Queries option is grayed out, ensure you have at least two queries loaded in the Queries pane. Refresh the data source or reload the tables if queries are missing.
  • If rows appear missing after union, check for empty tables in your source — Power Query ignores empty tables during append. Open each source query and use View > Advanced Editor to confirm it returns data.
  • If you see "Expression.Error: The key didn't match any rows in the table", a column in one table has been renamed or deleted after the union was created. Rebuild the union from scratch or edit the applied steps to remove the broken reference.
  • If the output table shows nulls in columns that should have data, revisit the column data types. A column labeled "Sales" in one table might be "sales" in another — case sensitivity matters.
  • If Power Query crashes during union on large datasets (over 500,000 rows), close other apps to free memory, or split the process: union five tables at a time, then union those results.
  • After loading, if Excel shows #VALUE! or #N/A errors, those are likely from formulas in the destination sheet referencing the unioned table. Replace them with structured references like Table1[Column1] or refresh the entire data model.

Frequently Asked Questions

Can I union tables with different column orders?

Yes. Power Query matches columns by name, not position. Even if "Date" is in column 2 in one table and column 5 in another, as long as both are named "Date", they’ll align correctly.

What happens if one table has extra columns?

Extra columns are added as new columns in the result with null values for rows from other tables. You can remove them later using the Remove Columns function.

Can I union tables from different files or databases?

Yes. Power Query can union tables from Excel files, CSVs, SQL Server, SharePoint, and more — as long as the column names and data types match across all sources.

Does union preserve the original order of rows?

Yes, rows are stacked in the order you select them in the Append dialog. To reorder, sort the final table after union.

Why does my unioned table show "Query1" instead of the real table names?

Power Query uses the query name, not the original source name. Rename your queries in the Queries pane (right-click > Rename) to something descriptive like "Sales_2023_Jan" before unioning.

Can I undo a union if I made a mistake?

Yes. In the Queries pane, right-click the unioned query and select Delete. You can then rebuild it from the original source queries. No data is lost — only the union step is removed.