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

M query or DAX query for left outer join

Need to create dax query or Mquery to join two tables SCD and Fosa on the key Internal_Key which is acomposite key formed with 

Internal_Key = SCD[Stichtag] & "_" & SCD[Depot] & "_" & SCD[WP ID]  in SCD Table
and  
Internal_Key = Fosa[Stichtag] & "_" & Fosa[Depot] & "_" & Fosa[WP ID] in FoSA Table
 
Can anyone help me with a dax script or M query?
1 ACCEPTED SOLUTION
v-diye-msft
Community Support
Community Support

Hi @Anonymous 

I’ve created 2 tables as requested, both of them added the calculated column “Internal_Key”, and we’d like to merge them based on that special column.

Assuming Fosa as the left table, and SCD as the right one.

 

  1. Using the function Addcolumns:
Table 2 = ADDCOLUMNS(Fosa,"SCD.WP ID",RELATED(SCD[WP ID]),"SCD.Stivhtag",RELATED(SCD[Stichtag]),"SCD.Depot",RELATED(SCD[Depot]),"SCD.Internal Key",RELATED(SCD[Internal_Key]))

1.PNG2. Using Merge option id query editor:

Create the custom column in both 2 tables using M code:

= Table.AddColumn(#"Changed Type1", "Custom", each Text.Combine({[Stichtag],"_",[Depot],"_",[WP ID]}))

1.PNG

And then Merge them using M code:

= Table.ExpandTableColumn(Source, "SCD", {"Stichtag", "Depot", "WP ID", "Custom"}, {"SCD.Stichtag", "SCD.Depot", "SCD.WP ID", "SCD.Custom"})

1.PNG

Regards,

Dina

 

Community Support Team _ Dina Ye
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

1 REPLY 1
v-diye-msft
Community Support
Community Support

Hi @Anonymous 

I’ve created 2 tables as requested, both of them added the calculated column “Internal_Key”, and we’d like to merge them based on that special column.

Assuming Fosa as the left table, and SCD as the right one.

 

  1. Using the function Addcolumns:
Table 2 = ADDCOLUMNS(Fosa,"SCD.WP ID",RELATED(SCD[WP ID]),"SCD.Stivhtag",RELATED(SCD[Stichtag]),"SCD.Depot",RELATED(SCD[Depot]),"SCD.Internal Key",RELATED(SCD[Internal_Key]))

1.PNG2. Using Merge option id query editor:

Create the custom column in both 2 tables using M code:

= Table.AddColumn(#"Changed Type1", "Custom", each Text.Combine({[Stichtag],"_",[Depot],"_",[WP ID]}))

1.PNG

And then Merge them using M code:

= Table.ExpandTableColumn(Source, "SCD", {"Stichtag", "Depot", "WP ID", "Custom"}, {"SCD.Stichtag", "SCD.Depot", "SCD.WP ID", "SCD.Custom"})

1.PNG

Regards,

Dina

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

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.