Append 12 Tables and Include Table Name

excelbytes

Active Member
Joined
Dec 11, 2014
Messages
291
Office Version
  1. 365
Platform
  1. Windows
Is it possible to append multiple tables in Power Query (which I am familiar with doing) and have it add a column with the table name similar to how it adds a source file name when you merge multiple files?
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Power Query:
let
    tables = {"TableA", "TableB","TableC"},
    t0 = Excel.CurrentWorkbook(){[Name=tables{0}]}[Content],
    Result = List.Accumulate(List.Skip(tables), Table.AddColumn(t0, "Source Table", each tables{0}), (s,c)=> 
                let tbl = Excel.CurrentWorkbook(){[Name=c]}[Content],
                    tbl1 = Table.AddColumn(tbl, "Source Table", each c)
                in  s & tbl1)
in
    Result

Book1
ABCDEFGHIJKLM
1TableATableBTableCQuery Output
2NameValueNameValueNameValueNameValueSource Table
3A6I3N6A6TableA
4B1J5O1B1TableA
5C3K1P3C3TableA
6D8L4Q2D8TableA
7E2M2R5E2TableA
8F5S4F5TableA
9G4G4TableA
10H7H7TableA
11I3TableB
12J5TableB
13K1TableB
14L4TableB
15M2TableB
16N6TableC
17O1TableC
18P3TableC
19Q2TableC
20R5TableC
21S4TableC
22
Sheet5
 
Upvote 0
Thanks, but I was hoping there was an option within Power Query to accomplish this. What I ended up doing was inserting a custom column and added the table name that way.
 
Upvote 0

Forum statistics

Threads
1,223,880
Messages
6,175,153
Members
452,615
Latest member
bogeys2birdies

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