Repeat Table 2 for each row of Table 1

ajaysomasi

New Member
Joined
Mar 6, 2017
Messages
25
Hi all

I need a help here.. I have a Table 1 with n rows (extracted from power query) and also Table 2 extracted from power query, placed in 2 tabs in Excel.. I require to place a new table in the 3rd tab..

The new table should be able to place 2nd table for each row of first table.. Below is an example, simplified with 2x2 table grids.. In reality, my tables are quite big, hence looking to do this in Power Query.. Request you to please advise.. Please note, there is no existing relationship between input tables (may be we need to bring in a variable to relate them??)..

Table 1 (simplified to 2x2 table):

Col ACol B
A1B1
A2B2


Table 2 (simplified to 2x2 table):

Col CCol D
C1D1
C2D2

Table 3 (Output):

Col ACol BCol CCol D
A1B1C1D1
A1B1C2D2
A2B2C1D1
A2B2C2D2
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Note: none of the tblx2 column names can be identical to any tblx1 names

Power Query:
let
    tbl1 = Excel.CurrentWorkbook(){[Name="tblx1"]}[Content],
    tbl2 = Excel.CurrentWorkbook(){[Name="tblx2"]}[Content],
    tbl = Table.AddColumn(tbl1,"all", each tbl2),
    tcn = Table.ColumnNames(tbl2),
    Result = Table.ExpandTableColumn(tbl, "all", tcn, tcn)
in
    Result

Book1
ABCDEFGHIJK
1tblx1tblx2query output
2
3Column1Column2Column3Column4Column1Column2Column3Column4
4A1B1C1D1A1B1C1D1
5A2B2C2D2A1B1C2D2
6A2B2C1D1
7A2B2C2D2
8
Sheet10
 
Upvote 0

Forum statistics

Threads
1,215,391
Messages
6,124,673
Members
449,178
Latest member
Emilou

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top