# Q: Power Query- Adding Custom Column Showing Table's Name



## Tuta (Nov 10, 2014)

All,

I'm trying to write a query that will add a custom column.  

In this custom column, I need the Table's name in each row.  I just can't seem to find out the proper way to grab the table's name and add it.

Thanks!


----------



## miguel.escobar (Nov 17, 2014)

what's the source of that table? is it a database or an excel table? Some of my vids could help you with this
http://www.youtube.com/watch?v=2g00mwxY5cs


----------



## Tuta (Nov 17, 2014)

Miguel -- it's a web page.

PQ finds several Tables available at the URL, I want to iterate through those tables, adding a custom column with each Table's name.


----------



## Tuta (Dec 6, 2014)

Anyone have any more ideas on this?


----------



## miguel.escobar (Dec 6, 2014)

it might be easier than what you think. I haven't tested this but you could go to the actual page and then expand the table from there. Kinda like the same approach when you import from folder but with web queries it always depends on how your source looks like


----------



## cody7290 (Aug 15, 2019)

Tuta said:


> Anyone have any more ideas on this?



I can't believe I figured this out.. lol I am always so dependent on the help of others I felt the need to share my findings.

I also am using a web page to pull several tables and wanted the "table name" to be associated with the data automatically. I wanted this not to be manual so the connection will be automated and auto input the unique table identifier. 

After you add all the tables you want from the URL if you highlight one at a time and select Advanced Editor it should show you a the source as a webpage and then a Data# = Source{#}[Data]. The Source # should be unique to each table it pulled in. That source # is referencing the table. Several minutes of tinkering led me to the following code for a custom column. "=Source{#}[Caption]". Adjust the # to whatever the source number shows on your table you are connected to on the URL.

I know this is from 2014 but I am still having this problem in 2019 and can't find a solution. This worked for me. Hopefully it is a good fix.


----------



## cody7290 (Aug 15, 2019)

cody7290 said:


> I can't believe I figured this out.. lol I am always so dependent on the help of others I felt the need to share my findings.
> 
> I also am using a web page to pull several tables and wanted the "table name" to be associated with the data automatically. I wanted this not to be manual so the connection will be automated and auto input the unique table identifier.
> 
> ...



Forgot to explain.

This works for my use because the source # will not change on my URL connection but the table names will all change. As long as I had the Source #'s matching the connection pull it will auto input the table name each time it updates. This may not work for every use but it will under these circumstances.


----------



## Tuta (Aug 15, 2019)

man --  I wish I could remember what I was trying to do!!


----------

