Power BI Table Combine Data: Step-by-Step
In this article
Combining tables in Power BI means merging or appending data from multiple tables into one, so you can analyze it as a single dataset. You can do this in two ways: Merge (join columns from two tables, like SQL JOIN) or Append (stack rows from two tables with the same columns). This guide covers both methods using Power Query Editor, the built-in tool for data transformation. You'll need Power BI Desktop (free) and your data sources ready—Excel files, CSV, SQL databases, or whatever you're using.
What You'll Need
- Power BI Desktop installed (free download from Microsoft's official site).
- Two or more tables loaded into Power BI (they can be from the same source or different sources).
- For merging: a common column (key) in both tables, like an ID or date.
- For appending: tables with the same column names (or at least the ones you want to stack).
Step-by-Step
Method 1: Merge Tables (Combine Columns)
- Open Power Query Editor: In Power BI Desktop, go to the Home tab and click Transform Data (or Edit Queries in older versions). This opens the Power Query Editor window.
- Select the first table: In the Queries pane on the left, click the table you want to be the base (the one that will keep all its rows).
- Start the merge: Go to the Home tab in Power Query Editor, click Merge Queries, and choose Merge Queries as New (if you want a new query) or just Merge Queries (to merge into the current table). For simplicity, choose Merge Queries as New.
- Choose the second table: In the dialog that appears, select the second table from the dropdown.
- Match the columns: Click on the column in the first table, then click on the matching column in the second table. They should be highlighted. If you need multiple columns, hold Ctrl and click each pair.
- Select the join kind: At the bottom, choose the join type (e.g., Left Outer, Inner, Full Outer). The default is usually fine for most cases. Click OK.
- Expand the new column: A new column with the second table's data will appear (usually named like the second table). Click the expand icon (double arrow) at the top-right of that column header.
- Choose columns to include: In the expand dialog, check the columns you want from the second table. Uncheck “Use original column name as prefix” if you want clean names. Click OK.
- Rename or adjust columns: Rename any columns as needed by double-clicking the header.
- Close & Apply: Go to Home tab and click Close & Apply to load the merged table into your data model.
Method 2: Append Tables (Stack Rows)
- Open Power Query Editor: Same as above, go to Transform Data.
- Select a table: In the Queries pane, click one of the tables you want to append. It doesn't matter which one first.
- Start the append: Go to Home tab, click Append Queries. Choose Append Queries as New to create a new query, or Append Queries to append to the current table. For a new query, select that option.
- Choose tables: In the dialog, select the second table (and more if you want) from the dropdown. You can add multiple tables by clicking the “Add” button. Click OK.
- Review the result: The new query will show all rows from both tables stacked. If columns don't match, Power Query will create new columns with nulls for missing data. You can edit the query to fix column mappings if needed.
- Close & Apply: Click Close & Apply to load the appended table.
Common Mistakes
- Mismatched data types: If the key columns are different types (e.g., one is text, the other is number), the merge will fail or produce no matches. Ensure they are the same type (convert using the column type icon in Power Query).
- Choosing the wrong join kind: Using Inner Join when you want all rows from the first table will drop unmatched rows. Use Left Outer if you want to keep all rows from the first table.
- Forgetting to expand the merged column: After merging, you must expand the new column to actually bring in the data. If you don't, you'll only see a column with “Table” values.
- Appending tables with different column names: If the columns have different names, Power Query will treat them as separate columns, creating extra columns with nulls. Rename columns to match before appending.
- Not checking for duplicate rows: Appending can create duplicates if the same rows exist in both tables. Consider removing duplicates if needed.
Tips
- Use Merge Queries as New to keep your original tables intact for other uses.
- Always check the data preview at the bottom of Power Query Editor before applying to catch issues early.
- For large datasets, use the “Fuzzy matching” option in merge if you have slight text differences, but use it carefully as it can be slow.
- If you need to combine more than two tables, you can chain merges or appends, or use the “Append Queries as New” multiple times.
- Rename your queries to something meaningful (like “Sales_Combined”) to keep your model organized.
Troubleshooting
- Merge returns no matching rows: Check the data types of the key columns. Also check for leading/trailing spaces or hidden characters. Use the “Trim” and “Clean” transformations in Power Query to fix text issues.
- Append creates extra columns: This happens when column names differ. Edit the appended query, select the extra columns, and remove them. Or rename columns in the source queries to match.
- Error saying “The key didn't match any rows”: This is often due to data type mismatch. Convert both columns to the same type (e.g., Text) before merging.
- The merged column doesn't expand: Click the expand icon, but if it's grayed out, it may be because the column is not a table type. Ensure you selected the correct join kind and that the second table has data.
- Performance is slow: If you're merging large tables, try to reduce the number of columns in the second table before merging (remove unnecessary columns). Also, consider using “Data Preview” to limit rows during development.
Frequently Asked Questions
Can I merge more than two tables at once?
No, the merge dialog only allows two tables at a time. But you can merge sequentially: merge the first two, then merge the result with the third, and so on.
What is the difference between Merge and Append?
Merge combines columns side-by-side based on a common key, like a VLOOKUP. Append stacks rows on top of each other, like pasting one table below another.
Do I need to have the same column names to append?
No, but it's recommended. If names differ, Power Query will create separate columns, which may not be what you want. You can rename columns in Power Query to match before appending.
Can I combine tables from different data sources?
Yes, as long as you have loaded them into Power BI. For example, you can merge an Excel table with a SQL table. Just make sure the key columns are compatible.
How do I undo a merge or append?
In Power Query Editor, you can remove the last applied step by clicking the “X” next to the step in the “Applied Steps” pane on the right. This will revert to the previous state.
Why is my merged data showing “null” for some rows?
This is normal if you use a Left Outer join and there are no matching rows in the second table. Nulls indicate missing matches. You can filter them out if needed.