Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply

Merge 2 tables into one table

Hi all, 

 

I have 2 different datasets uploaded in Power Bi as 2 different tables. These 2 tables are quite different but the unique identifier is the email address. However sometimes a contact is in one table but not in the other. What i would like to get is to merge the 2 tables into 1 and get all the fields from both tables.

 

There is an example below and the desired outcome.

 

Is this something possible in Power Bi?

 

Alessandro-laba_0-1618585617005.png

 

Thanks,

Ale

1 ACCEPTED SOLUTION
v-cazheng-msft
Community Support
Community Support

Hi @Alessandro-laba 

You can create a new pbix file with these two tables(Merge and NATURALLEFTOUTERJOIN don't support tables from Power BI datasets) and try these steps.

 

1 Remove ‘company’ column of Table 2 in Power Query

v-cazheng-msft_0-1618902303386.png

 

2 Rename the ‘email address’ column of Table 1(NATURALLEFTOUTERJOIN doesn’t support Duplicate column names used for join)

v-cazheng-msft_1-1618902303389.png

 

3 Create a Calculated table with NATURALLEFTOUTERJOIN function

Table =

VAR join_table =

    NATURALLEFTOUTERJOIN ( Table2, Table1 )

RETURN

    SELECTCOLUMNS (

        join_table,

        "first name", [first name],

        "last name", [last name],

        "company", [company],

        "Name", [Name],

        "country", [country],

        "email address", [email address]

    )

 

The result looks like this:

v-cazheng-msft_2-1618902303390.png

 

For more details, you can refer the attached pbix file.

 

Best Regards

Caiyun Zheng

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
v-cazheng-msft
Community Support
Community Support

Hi @Alessandro-laba 

You can create a new pbix file with these two tables(Merge and NATURALLEFTOUTERJOIN don't support tables from Power BI datasets) and try these steps.

 

1 Remove ‘company’ column of Table 2 in Power Query

v-cazheng-msft_0-1618902303386.png

 

2 Rename the ‘email address’ column of Table 1(NATURALLEFTOUTERJOIN doesn’t support Duplicate column names used for join)

v-cazheng-msft_1-1618902303389.png

 

3 Create a Calculated table with NATURALLEFTOUTERJOIN function

Table =

VAR join_table =

    NATURALLEFTOUTERJOIN ( Table2, Table1 )

RETURN

    SELECTCOLUMNS (

        join_table,

        "first name", [first name],

        "last name", [last name],

        "company", [company],

        "Name", [Name],

        "country", [country],

        "email address", [email address]

    )

 

The result looks like this:

v-cazheng-msft_2-1618902303390.png

 

For more details, you can refer the attached pbix file.

 

Best Regards

Caiyun Zheng

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

VijayP
Super User
Super User

@Alessandro-laba 

In Power Query you can use Merge Queries option to get this result

First Add these two tables to Power Query .

Using the similar column , Merge the tables and expand to the result

 




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.