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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors