DEV Community

Cover image for Power BI: Two ways to Union Tables - DAX and Power Query
Luca Liu
Luca Liu

Posted on

Power BI: Two ways to Union Tables - DAX and Power Query

How to Union Two Tables in Power BI: A Comprehensive Guide

Combining data from multiple tables is a common requirement in Power BI to create unified datasets for analysis and visualization. There are two primary methods to achieve this task in Power BI: using the DAX UNION function and using the Append Queries feature in Power Query. In this guide, we will walk you through the step-by-step process of both methods.

Method 1: Using DAX UNION Function

The DAX UNION function allows you to combine two or more tables with identical columns into a single table. Here's how you can use the UNION function in Power BI:

  1. Launch Power BI Desktop and load the tables that you want to union.
  2. Go to the Modeling tab on the Power BI ribbon.
  3. Click on New Table to create a new DAX table.

    Image description

  4. Enter the following DAX formula to union two tables, for example:

    Table = UNION('Query1','Query2')
    
  5. Replace 'Query1' and 'Query2' with the actual table names you want to union.

  6. Press Enter to create the new table with the combined data from both tables.

Method 2: Using Append Queries in Power Query

Appending queries in Power Query allows you to combine tables by stacking one on top of the other. Here's a step-by-step guide to using the Append Queries feature:

  1. Load the tables into Power Query by selecting the table and clicking on the Transform Data option.
  2. In the Power Query Editor, select the first table you want to append.
  3. Go to the Home tab on the Power Query ribbon.
  4. Click on Append Queries and select Append Queries as New.

    Image description

  5. Choose the second table you want to append in the dialog box that appears.

  6. Configure the append operation by selecting the appropriate options (e.g., append queries with matching columns).

  7. Click OK to append the tables.

  8. Once appended, you can further transform the data or load it into Power BI for analysis.

Conclusion

By following these two methods, you can effectively union two tables in Power BI using either DAX or Power Query. Choose the method that best suits your data structure and analysis requirements to seamlessly integrate and consolidate your datasets.


Explore more

Thank you for taking the time to explore data-related insights with me. I appreciate your engagement.

🚀 Connect with me on LinkedIn

🎃 Connect with me on X

Top comments (0)