+ Reply to Thread
Results 1 to 6 of 6

Add sheet name as a column in appended tables in Power Query

  1. #1
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,063

    Add sheet name as a column in appended tables in Power Query

    Time to take a big breath and learn about Power Query.

    It seems reasonably intuitive, but....

    The enclosed file has two tables, on in each of two sheets. I can append them and do all sorts of stuff. However, I want to to be able to import the sheet name as a column into the appended tables.

    I don't want to create an extra column, on each raw data sheet, repeating the column name... That's ugly (and easy...). There must be some way of adding the sheet name as a column when appending the tables. I just can't see where.. and my efforts on Google have led me up just so many blind alleys.

    So, over to my fellow Excellers...

    More daft questions will follow in time...
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,931

    Re: Add sheet name as a column in appended tables in Power Query

    I’m on the iPad now, Glenn, but I think that if you go with a blank query, make the source =Excel.CurrentWorkbook(), then you will get a sheet name column by default.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,931

    Re: Add sheet name as a column in appended tables in Power Query

    This: https://exceloffthegrid.com/power-qu...rent-workbook/

    Yes, it’s high time you took PQ on!!!

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,063

    Re: Add sheet name as a column in appended tables in Power Query

    I'm off for a beer or twain... I did try that... but when I did... sod-all happened...

    I'll be back tomorrow...

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,931

    Re: Add sheet name as a column in appended tables in Power Query

    It relies on there being tables or named ranges, but have another go tomorrow. Enjoy your brew!

    I use this technique a fair bit, so yes, it should work!

  6. #6
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Add sheet name as a column in appended tables in Power Query

    Excel.CurrentWorkbook only read table name, not sheet name.

    Option 1 rename each table name to Bert and Ernie

    Please Login or Register  to view this content.
    Option 2 use Excel.Workbook to get data from sheet with sheet name. Change the file path in blue.
    Please Login or Register  to view this content.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Power Query/Power Pivot Conditional Column creation & chart
    By mz_h in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-12-2020, 06:07 PM
  2. Replies: 10
    Last Post: 06-25-2020, 12:19 AM
  3. Power Query: Updating a query based on changing tables
    By cheesehead101 in forum Excel General
    Replies: 1
    Last Post: 12-16-2019, 06:54 PM
  4. [SOLVED] Power Pivot does not load new column added in Power query
    By ibuhary in forum Excel General
    Replies: 12
    Last Post: 02-19-2019, 03:53 AM
  5. Power Query tables in VBA
    By orhanceliloglu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-26-2018, 08:25 AM
  6. [SOLVED] Multiple tasks on tables in Power Query
    By wrybel in forum Excel General
    Replies: 11
    Last Post: 08-01-2017, 03:17 AM
  7. Power Query - how to append tables
    By GIS2013 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-25-2015, 04:55 AM

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