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
Anonymous
Not applicable

Combine (merge) two data tables depending on entries in power query

Hi,

 

This is a simplifed version of my data.

I have two tables 1 and 2. I want to merge them in a way that will result in table final.

Table1 is a master data table and all of them should appear in the final table. 

Table2 is going to be added (merged) to Table1.

 

The important conditions for merging are:

  • If a Person from Table2 is not available in Table1, then ignore it (do not include any of its entries in Table2 in merging) ("Andy") (=left join?).
  • If a Person is available in Table1 and not in Table2, still include all its entries in final table ("Zoe") (=left join).
  • If a Person from Table2 is available in Table1, then do full outer join for that Person ("Jack", "Michael", and "Sarah").

 

Table1: 

NoPersonUnitClassStatus_R
1JackATTAM
2JackACPRO
3JackAPPEM
4MichaelBTTAM
5MichaelBCPRO
6MichaelBPPER
7SarahCTTAM
8SarahCCPRM
9SarahCPPEM
10ZoeDTTAO
11ZoeDCPRR
12ZoeDPPER

 

 

Table2: 

NoPersonClassStatus
1JackABSC
2JackTTAP
3JackCPRD
4MichaelABSC
5MichaelXYZC
6SarahTTAP
7SarahPPED
8SarahCPRD
9AndyABSC
10AndyTTAC

 

 

Result Table - After combining:

NoPersonUnitClassStatus_RStatus
1JackATTAMP
2JackACPROD
3JackAPPEM 
4JackAABS C
5MichaelBTTAM 
6MichaelBCPRO 
7MichaelBPPER 
8MichaelBABS C
9MichaelBXYZ C
10SarahCTTAMP
11SarahCCPRMD
12SarahCPPEMD
13ZoeDTTAO 
14ZoeDCPRR 
15ZoeDPPER 

 

 

Can someone please help in doing this task?

Thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I found a solution to this.

 

I created this table which contains unique info of persons:

 

Table0: 

NoPersonUnit
1JackA
2MichaelB
3SarahC
4ZoeD

 

Then, merged Table2 with Table0 (right join on Table0) to create a new modified Table2. This removes all extra ones, such as "Andy" entries.

This new table was then full outer joined on Table1.

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

I found a solution to this.

 

I created this table which contains unique info of persons:

 

Table0: 

NoPersonUnit
1JackA
2MichaelB
3SarahC
4ZoeD

 

Then, merged Table2 with Table0 (right join on Table0) to create a new modified Table2. This removes all extra ones, such as "Andy" entries.

This new table was then full outer joined on Table1.

 

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.