+ Reply to Thread
Results 1 to 9 of 9

Row values as column headers and totals per value

  1. #1
    Registered User
    Join Date
    07-11-2017
    Location
    Edhome, where else?
    MS-Off Ver
    365
    Posts
    52

    Row values as column headers and totals per value

    Hi all,

    I would like to pivot this table so
    - each unique value in column Months/TAGS will be a columnheader and
    - each columnheader (besides Months/TAGS) will be a row value in the 1e column (and state the totals per column)

    Can someone help me with this in Power Query? (I'dont want to solve this with a regular Pivottable)

    T pq.JPG


    Attached you find the excel sheet with both tables (Table1 and Table2)

    Thank you in advance.
    Attached Files Attached Files
    Last edited by mamaexcel; 01-12-2024 at 10:25 AM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,257

    Re: Row values as column headers and totals per value

    Your attachment doesn't work for me, but it looks like you basically need to unpivot all columns other than the first one, then repivot on the Month/Tags column.
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    07-11-2017
    Location
    Edhome, where else?
    MS-Off Ver
    365
    Posts
    52

    Re: Row values as column headers and totals per value

    Hi Rory,

    Can you tell me what's not working in my attachment?

    I've been trying to accomplish what you suggest but I'm not experienced with PQ so I can't figure it out.
    Can you assist me with it?

  4. #4
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,372

    Re: Row values as column headers and totals per value

    Do you still use Excel 2016?
    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.

  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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,372

    Re: Row values as column headers and totals per value

    If you have the lastest (beta) release of 365:

    =HSTACK(TRANSPOSE(Table1[#Headers]),TRANSPOSE(GROUPBY(Table1[Month/TAGS],Table1[[OKT]:[DEC]],SUM,0,0)))

    With PQ:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by AliGW; 01-13-2024 at 06:14 AM.

  6. #6
    Registered User
    Join Date
    07-11-2017
    Location
    Edhome, where else?
    MS-Off Ver
    365
    Posts
    52

    Re: Row values as column headers and totals per value

    I'm on Office365 now (will update my profile, thanks)

    Your formula works great, thank you!
    I will keep this in mind for future use or if it's not possible to solve my need in PQ.

    For this issue it's not really practical to use it as Table1 is actually not plotted on a worksheet (no need for) so Table1 it's just referenced in PQ.

  7. #7
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,372

    Re: Row values as column headers and totals per value

    I gave you the PQ solution as well. If the table is connection only, just change the source of the query.

    Please update your forum profile.

  8. #8
    Registered User
    Join Date
    07-11-2017
    Location
    Edhome, where else?
    MS-Off Ver
    365
    Posts
    52

    Re: Row values as column headers and totals per value

    My apologies, I just copied your formula in my workbook and overlooked that you had added your version with the PQ code as well.

    And yes, that is exactly what I was looking for. Lessons learned.

    Thank you so much for you help, I really appreciate it.

    Best regards,

    mamaexcel

  9. #9
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,372

    Re: Row values as column headers and totals per value

    Glad to have helped.

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of each of those who offered help.

+ 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] Concatenate Column Headers with Values
    By raghibakhter in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-07-2022, 12:05 AM
  2. Replies: 3
    Last Post: 06-19-2018, 03:37 AM
  3. Replies: 1
    Last Post: 06-19-2018, 03:15 AM
  4. [SOLVED] How to reference row values using column headers
    By MyStix01 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-16-2018, 01:47 AM
  5. Retrieve Column Headers Dynamically - Based on column Values
    By akshaysudhir in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-12-2016, 05:42 AM
  6. [SOLVED] Cell Values Become Column Headers
    By nalani24 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-05-2013, 03:35 PM
  7. Replies: 2
    Last Post: 05-09-2012, 01:30 PM

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