paint-brush
Power BI: Two ways to Union Tables - DAX and Power Queryby@luca1iu
14,466 reads
14,466 reads

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

by Luca LiuMarch 20th, 2024
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Combining data from multiple tables is a common requirement in Power BI. There are two primary methods to achieve this task. Using the DAX UNION function and using the Append Queries feature in Power Query are the best ways to do it. By following these two methods, you can effectively union two tables in power BI.
featured image - Power BI: Two ways to Union Tables - DAX and Power Query
Luca Liu HackerNoon profile picture

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 the 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.

  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 a 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.

  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 integrate and consolidate your datasets seamlessly.


Thank you for taking the time to explore data-related insights with me. I appreciate your engagement. If you find this information helpful, I invite you to follow me or connect with me on LinkedIn or X(@Luca_DataTeam). You can also catch glimpses of my personal life on Instagram, Happy exploring!👋