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
NittanyBlu
New Member

Make New Table from columns of existing tables that have relationship

I'd like to make a new table based on the existings tables I currently have (which have relationships). How do I do this?

 

I have three current table... examples:

Table 1. Employee Information

Employee NameUser ID
PeteID1234
KimID4321

      * UserID field from Employee Information Table has a 1-to-many relationship with the UserID field of Employee Assignment Table

Table 2. Employee Assignments

UserIDAssignment Code
ID1234A001
ID4321A001
ID4321A002

     * Assignment Code field from the Employee Assignments table has many-to-many relationships with the Assignment code field from the Assignment to Customer Relationships table (Employee Assignment filters - Assigment to Customer Relationship).

Table 3. Assignment to Customer Relationships

Assignment CodeCustomer Name
A001Bob's Tackle
A001Lisa's Cafe
A002Joe's Garage
A002Jack's Painting

 

My goal is to create a forth table based on the current tables and relationships. This new table would look like the following:

Employee NameCustomer Name
PeteBob's Tackle
PeteLisa's Cafe
KimBob's Tackle
KimLisa's Cafe
KimJoe's Garage
KimJack's Painting

 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

In the Query Editor, merge table3 into table2 and then table2 into table1.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

2 REPLIES 2
v-lionel-msft
Community Support
Community Support

Hi @NittanyBlu ,

 

let
    Source = Table.NestedJoin(Table, {"User ID"}, #"Table (2)", {"UserID"}, "Table (2)", JoinKind.LeftOuter),
    #"Expanded Table (2)" = Table.ExpandTableColumn(Source, "Table (2)", {"UserID", "Assignment Code"}, {"Table (2).UserID", "Table (2).Assignment Code"}),
    #"Merged Queries" = Table.NestedJoin(#"Expanded Table (2)", {"Table (2).Assignment Code"}, #"Table (3)", {"Assignment Code"}, "Table (3)", JoinKind.LeftOuter),
    #"Expanded Table (3)" = Table.ExpandTableColumn(#"Merged Queries", "Table (3)", {"Assignment Code", "Customer Name"}, {"Table (3).Assignment Code", "Table (3).Customer Name"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Table (3)",{"User ID", "Table (2).UserID", "Table (2).Assignment Code", "Table (3).Assignment Code"})
in
    #"Removed Columns"

v-lionel-msft_0-1615169518261.png

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Ashish_Mathur
Super User
Super User

Hi,

In the Query Editor, merge table3 into table2 and then table2 into table1.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.