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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
smpa01
Super User
Super User

Merging a single table to multiple tables at once

Hi everyone,

 

Is it possible for PQWRY to mege one table to multiple tables at once.

 

The sample data is here- https://drive.google.com/open?id=1fBe0MNgoVnpspiZJwzQJHMhzlS1nYqpP

 

I want to know if it is possible at all to Merge ID column of MASTERID table to RAWDATA1 and RAWDATA2 ID column at once to reach to the DESIRED table. The objective of this task is to find out if there is a capacity exists withing PQWRY that eliminates the need to merge queries repeatedly to reach to the "DESIRED". The easy alternative #1 is definitley repeated Merging Queries followed by applying Logical Operators to come the "Desired" which is difficult to do when the number of RAWDATA table increases. The easy alternative #2 is Appending all the RAWDATA to a single table which is not also an option as each of the RAWDATA tables has a lot of steps that make the APPENDING a long time consuming task.

 

I tried doing the following which offcourse did not work and I was wondering if anyone has a trick up their sleeve to achieve what I want.

Capturexxxxxxxx.JPG

 

 

Thank you in advance.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
1 ACCEPTED SOLUTION

Hi, @smpa01

Based on my test, it’s not able to merge three tables in one step with Merge Queries feature, but we can use nested Table.NestedJoin function in Power Query to do it. You can refer to below steps in query editor:

1.Open the “Advanced Editor” of the  ‘MASTEDID’ table and enter the code:

let

    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxmDSBEyagkkzpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ID = _t]),

    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}}),

    #"Merge three tables" = Table.CombineColumns(Table.ExpandTableColumn(Table.ExpandTableColumn(Table.NestedJoin(Table.NestedJoin(#"Changed Type",{"ID"},RAWDATA1,{"ID"},"RAWDATA1",JoinKind.LeftOuter),{"ID"},RAWDATA2,{"ID"},"RAWDATA2",JoinKind.LeftOuter), "RAWDATA1", {"Name"}, {"RAWDATA1.Name"}),

"RAWDATA2", {"Name"}, {"RAWDATA2.Name"}),{"RAWDATA1.Name", "RAWDATA2.Name"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged")

in

#"Merge three tables"

XYZ1.PNG

2.Click the “Done” and you can see the correct result.

xyz.PNG

You can also download the PBIX file to have a view.

  https://www.dropbox.com/s/bedqzgi3pmkmzvi/Merging%20a%20single%20table%20to%20multiple%20tables%20at...

 

Regards,

Daniel He

 

Community Support Team _ Daniel He
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

5 REPLIES 5
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @smpa01,

I want to know the meaning of “at once” you mentioned in your problem. If you want to append two columns and merge another column by one step, you can refer to below steps in query editor:

1.Click the Table ‘RAWDATA1’ and open the “Advanced Editor” function.

1.PNG

2.Add the sentence  #"Desired" = Table.RemoveColumns(Table.NestedJoin(Table.Combine({#"Changed Type", RAWDATA2}),{"ID"},MASTEDID,{"ID"},"MASTEDID",JoinKind.LeftOuter),{"MASTEDID"})

before the “in” and replace the sentence #"Changed Type" with the #"Desired" like the picture below.

2.PNG

Now you can see the result.

3.PNG

You can also download the PBIX file to have a view.

https://www.dropbox.com/s/vlpe08m7cuyauxo/Merging%20a%20single%20table%20to%20multiple%20tables%20at...

 

Regards,

Daniel He

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

@v-danhe-msftthanks for your reply.

 

"I want to know the meaning of “at once” you mentioned in your problem" -

"at once" means

merging MASTERID table to "RAWDATA1" and "RAWDATA2" in a single step

instead of

merging MASTERID table firstly to "RAWDATA1" and finally to "RAWDATA2" in two (2) different steps

 

The solution that you provided is not the one I am looking for. Perhaps I did not explain my problem in great lenth and that's why it was perceived differently by you.

 

You have simply appended RAWDATA1 and RAWDATA2 to come to the "DESIRED" which is not what I want. I want MASTERID to be merged to "RAWDATA1" and "RAWDATA2" at once to come to the "DESIRED".

 

Please take a look at the modified MASTERID table which needs to be Merged to RAWDATA1 and RAWDATA2 at once (if possible) to come to modified "DESIRED".

 

MASTERIDMASTERIDDESIREDDESIRED

 To give you a better illustration presently I am doing this

Merging 1Merging 1

 and this after merging 1

 

Merging 2Merging 2

instead I want the following at once (if possible in a single Merging Queries step)

 

DESIREDDESIRED

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Hi, @smpa01

Based on my test, it’s not able to merge three tables in one step with Merge Queries feature, but we can use nested Table.NestedJoin function in Power Query to do it. You can refer to below steps in query editor:

1.Open the “Advanced Editor” of the  ‘MASTEDID’ table and enter the code:

let

    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxmDSBEyagkkzpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ID = _t]),

    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}}),

    #"Merge three tables" = Table.CombineColumns(Table.ExpandTableColumn(Table.ExpandTableColumn(Table.NestedJoin(Table.NestedJoin(#"Changed Type",{"ID"},RAWDATA1,{"ID"},"RAWDATA1",JoinKind.LeftOuter),{"ID"},RAWDATA2,{"ID"},"RAWDATA2",JoinKind.LeftOuter), "RAWDATA1", {"Name"}, {"RAWDATA1.Name"}),

"RAWDATA2", {"Name"}, {"RAWDATA2.Name"}),{"RAWDATA1.Name", "RAWDATA2.Name"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged")

in

#"Merge three tables"

XYZ1.PNG

2.Click the “Done” and you can see the correct result.

xyz.PNG

You can also download the PBIX file to have a view.

  https://www.dropbox.com/s/bedqzgi3pmkmzvi/Merging%20a%20single%20table%20to%20multiple%20tables%20at...

 

Regards,

Daniel He

 

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

@v-danhe-msftThanks Daniel for the reply. I have not had the time to go through the solution yet. I will get back to you soone. Thans for your time.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

@v-danhe-msftI have tested the code and it works for me. It is a nice work around to "at once". You are nesting multiple mergings at once and it would save me some time. I had to disect your code by parts to understand and hence, the delay.

Thanks for the help mate !!! Below is your code broken down in parts

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxmDSBEyagkkzpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ID = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}}),
    #"Merged Queries" = Table.NestedJoin(Table.NestedJoin(#"Changed Type",{"ID"},RAWDATA1,{"ID"},"RAWDATA1",JoinKind.LeftOuter),{"ID"},RAWDATA2,{"ID"},"RAWDATA2",JoinKind.LeftOuter),
    #"Expanded RAWDATA1" = Table.ExpandTableColumn(#"Merged Queries", "RAWDATA1", {"Name"}, {"Name"}),
    #"Expanded RAWDATA2" = Table.ExpandTableColumn(#"Expanded RAWDATA1", "RAWDATA2", {"Name"}, {"Name.1"}),
    #"Merged Columns" = Table.CombineColumns(#"Expanded RAWDATA2",{"Name", "Name.1"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged")
in
    #"Merged Columns"

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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