+ Reply to Thread
Results 1 to 3 of 3

Add column that shows source table names in Power Query?

  1. #1
    Registered User
    Join Date
    01-16-2009
    Location
    Hartford, CT
    MS-Off Ver
    Excel 2010
    Posts
    50

    Add column that shows source table names in Power Query?

    I'm using Power Query to join three tables. In the results, I'd like there to be a column that shows the source table names.
    I know I could add an identifying column to each table before creating the query, but that solution isn't ideal. Is there a way to do it in PQ?
    Thanks!

  2. #2
    Valued Forum Contributor
    Join Date
    10-13-2010
    Location
    UK
    MS-Off Ver
    various
    Posts
    941

    Re: Add column that shows source table names in Power Query?

    I'm no expert on PQ but, given lack of response to your post thus far...

    Do you not have the option to Add a "Custom Column" in PQ Editor {via Add Column tab}?
    If so, add the Custom Column and set = Table Name, as a constant, e.g. ="Table X"; repeat for the other two tables / queries.

    edit: added working example... I did this using O365, but hopefully you will be able to see the definition in 2010 PQ {I don't know if the Editor is different}; in short - created three connections (one per table), each with a Custom Column added in PQ, and subsequently appended the 3 connections.
    Attached Files Attached Files
    Last edited by XLent; 02-13-2019 at 05:13 AM.

  3. #3
    Registered User
    Join Date
    01-16-2009
    Location
    Hartford, CT
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: Add column that shows source table names in Power Query?

    Ahhh, I see what you did there. That is helpful and a bit more elegant than creating new columns directly in the spreadsheet itself. I was thinking, though, that there HAD to be a way to add only ONE additional column, within the query results, that somehow derived the source table name for each row and displayed that value. From what I'm finding, that is actually NOT the case. That surprises me. It seems like a common need, when dealing with multiple tables of data that get combined...users would want to know from which table the data was derived. Oh well...I appreciate this valuable tip, nonetheless. Thank you

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1