Yes, you can combine tables in Power BI Desktop by using the Append Queries feature in the Power Query Editor. This merges data from different sources—such as separate Excel files, CSVs, or database tables—into a single, consistent dataset. Before starting, ensure both tables share at least one common column, such as a unique ID or date, as this is required for Power BI to align the rows correctly.
What You'll Need
- Power BI Desktop installed on your computer.
- At least two data sources (e.g., two Excel files, two CSVs, or two tables in a database) that you want to merge.
- A basic understanding of Power Query, including the ability to open the "Transform Data" button from the Home tab.
- A column of data that exists in both tables, which will be used to match and align rows (e.g., a "CustomerID" or "Date" column).
Step-by-Step
- Open your Power BI Desktop file. Click on the "Transform Data" button located in the Home ribbon. This opens the Power Query Editor, where you will perform the actual data combination.
- Load your data into the Editor. If you have not already loaded your data, you will need to load it. Click "Get Data" in the Home ribbon, select your data source (e.g., Excel, CSV), navigate to the files, and load them into the data model. You can repeat this for each table you wish to combine.
- Select the first table to append. In the Queries pane on the left side of the window, click on the first table you want to include in the combined dataset. This is the primary table that will serve as the foundation.
- Open the Append Queries dropdown. With the first table selected, go to the Home ribbon and click on the small arrow next to the "Append Queries" button. This reveals a submenu with several options, including "Append Queries as New" and "Append Queries as New (All Rows)." For standard table combining, you will typically select the first option.
- Choose the Append Queries as New option. This action will open the "Append Queries" dialog box. The dialog is designed to help you select the second table and define the relationship between the two.
- Select the second table. In the Append Queries dialog, look for the "Tables” section. You will see a list of all the queries available in your Power BI model. Select the second table you want to combine from this list. You can add more than two tables to this list if needed, but the process remains the same.
- Define the join kind (optional). The dialog typically defaults to a "Left Outer” join kind. This means it will take all rows from the first table and append rows from the second table that match on the common column. This is usually the correct setting for combining tables. You can change this to "Inner,” “Right Outer,” or “Full Outer” if your specific data requirements demand a different type of join. For most simple table combines, however, the default is sufficient.
- Identify the key column. The dialog will ask for a “Key Column.” This is the column that exists in both tables and will be used to match rows. Select the appropriate column from the dropdown list for each table. For example, if both tables have a column named “ProductID,” select “ProductID” for the first table and “ProductID” for the second table. This ensures that Power BI correctly aligns the data.
- Click OK. Once you have selected the second table and the key column, click the “OK” button in the bottom right corner of the dialog. Power Query will now process the two tables. Depending on the size of your data, this may take a few seconds to a minute.
- Review the combined table. After the process is complete, you will see a new query in the Queries pane. This new query represents the combined table. You can click on it to view its data in the main Power Query Editor window. You will notice that the columns from the second table have been appended to the end of the first table. If a row in the second table has no matching key value in the first table, the columns from the first table will show as null values.
- Close and Apply. Once you are satisfied with the combined data, click the “Close & Apply” button in the Home ribbon. This will load the combined table back into the main Power BI Desktop window, where you can now use it to create your reports and visualizations.
Common Mistakes
One of the most frequent mistakes is attempting to combine tables that do not share a common column. Power Query requires a key column to align rows. If you try to append a table of sales data to a table of customer demographics without a shared ID, the data will be misaligned, leading to incorrect analysis. Always verify that your tables have at least one column with identical data types and values that can be used for matching.
Another mistake is using the wrong join kind. The default “Left Outer” join is great for adding data to the main table, but it will not include rows that exist only in the second table. If you need to see all data from both tables, you must select the “Full Outer” join kind in the Append Queries dialog. This ensures that no data is lost from either source.
Users also often fail to clean their data before combining it. If one table has a column named “Customer ID” with spaces and the other has “CustomerID” without spaces, Power Query will treat them as two different columns. You should go into Power Query and use the “Replace Values” or “Split Column by Delimiter” features to standardize your column names and data formats before you attempt to append them.
Tips
When appending queries, it is good practice to rename your queries after you combine them. A combined query named “Combined_Sales_Data” is much easier to understand than a generic name like “Query15.” You can rename a query by right-clicking on it in the Queries pane and selecting “Rename.”
Always check the data types of your key columns before you start. If one key column is set to “Text” and the other is set to “Whole Number,” Power Query may not be able to match them correctly. You can change the data type by right-clicking on the column header and selecting “Change Type.”
If you are working with a large number of tables, it can be tedious to select them one by one in the Append Queries dialog. A helpful tip is to select the first table, then hold down the Shift key and click on the last table you want to include. This will select a range of tables. Then, right-click on one of the selected tables and choose “Append Queries as New.” This is a much faster way to combine multiple tables.
Troubleshooting
If you see an error message in the Power Query Editor after trying to append queries, the most common cause is a data type mismatch in the key column. To fix this, click on the problematic column header and select “Change Type.” Choose the most appropriate data type that matches the data in the column, such as “Whole Number,” “Decimal Number,” or “Text.”
If you find that your combined table has many null values, it usually means that the key column is not matching correctly. This can happen if the data in the key column is not exactly the same. For example, if one table has “123” and the other has “123”, they will not match. Use the “Replace Values” feature in Power Query to standardize your data before appending.
If your combined table is not loading back into Power BI Desktop, check the “Home” ribbon for a progress bar or error message. Sometimes, the error message will be hidden behind a button or a small window. Click on the “Home” tab and look for any red exclamation marks or error notifications. If you see an error, click on it to get more details about what went wrong.
Frequently Asked Questions
Can I combine tables from different sources using Power Query?
Yes, you can. Power Query is designed to work with data from a wide variety of sources, including Excel, CSV, SQL Server, and web pages. As long as both tables are loaded into the Power BI data model, you can append them using the same steps described above.
What is the difference between Append Queries and Merge Queries?
The main difference is that Append Queries adds rows to the bottom of a table, while Merge Queries adds columns to the side of a table. Use Append Queries when you have data from different sources that you want to analyze together, such as sales data from two different years. Use Merge Queries when you want to combine data from two tables based on a common key, such as adding customer demographics to sales data.
What happens to the original tables after I append them?
The original tables remain unchanged in your Power BI model. The Append Queries operation creates a new, separate query that contains the combined data. You can continue to use, edit, or delete the original tables without affecting the combined table.
How do I handle tables with different columns when appending?
When you append tables, Power BI will create a new column for each column in the second table. If a row in the first table does not have a corresponding value in the second table, the new column will show null. You can then use Power Query to filter out these null values or replace them with default values.
Can I append tables that are already part of a relationship in the data model?
Yes, you can. However, it is generally not recommended to append tables that are already related. If you have a relationship between a “Sales” table and a “Products” table, you should merge the products into the sales table, rather than appending the sales tables together. Appending related tables can lead to confusing and incorrect data models.
Is there a limit to the number of tables I can append at once?
There is no hard limit on the number of tables you can append in Power Query. However, performance may degrade if you try to append a very large number of tables or tables with millions of rows. It is often better to append smaller groups of tables and then merge those combined tables together later.