Add "Name" Column in Power Query - Append

mwl_y

New Member
Joined
May 23, 2024
Messages
17
Office Version
  1. 365
Platform
  1. Windows
When making a query with multiple tables, a column called "Name" is automatically created, containing the table name...
When appending queries, however, it doesn't do this. Is there a way to add a "Name" column to my appended query, so I can see which query the data came from?

My queries (TemplatePerson and TemplatePerson2) are "connection only", as I do not want them to physically reside in my workbook, but "Append1" will be loaded to a new sheet.
1718310159653.png
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
add a new column in each table with the name of that table. Make sure the two tabels have te same headernames(exactly). Then you can append
 
Upvote 0
Try creating a blank query and insert the code below.
Change the Filter to be whatever you need it to be to pick up the tables you want.
Then Expand the Tables column to pick up the fields you want in the output.

Power Query:
let
    Source = Excel.CurrentWorkbook(),
    #"Filtered Rows" = Table.SelectRows(Source, each Text.StartsWith([Name], "TemplatePerson"))
in
    #"Filtered Rows"
 
Upvote 0
Power Query:
    Record.ToTable(
        Record.SelectFields(
            #shared,
            {"TemplatePerson", "TemplatePerson2"}
        )
    )
Thanks, I think this is what I need; I'm still quite new to using Power Query - where would I insert this code? This is what is currently in the editor:

Power Query:
let
    Source = Table.Combine({TemplatePerson, TemplatePerson2})
in
    Source
 
Upvote 0
Try creating a blank query and insert the code below.
Change the Filter to be whatever you need it to be to pick up the tables you want.
Then Expand the Tables column to pick up the fields you want in the output.

Power Query:
let
    Source = Excel.CurrentWorkbook(),
    #"Filtered Rows" = Table.SelectRows(Source, each Text.StartsWith([Name], "TemplatePerson"))
in
    #"Filtered Rows"
Thanks, but unfortunately this won't work... as mentioned, I'm appending queries, not using tables from the same workbook
On a side note, "TemplatePerson" is a placeholder name - these queries will have different names (think Amy, Bob, Dave, etc)
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,107
Members
453,021
Latest member
Justyna P

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