+ Reply to Thread
Results 1 to 13 of 13

Pivot columns and Extract without PowerQuery

  1. #1
    Forum Contributor
    Join Date
    12-03-2020
    Location
    australia
    MS-Off Ver
    365
    Posts
    112

    Pivot columns and Extract without PowerQuery

    I have a problem which I can solve using PowerQuery but I need a formula to do it as PowerQuery doesn't allow me to update the data set with new headers and columns.

    Raw data

    1.jpg

    From my raw data, I've highlighted the columns I need. Note that the patterns for the columns repeat. In the raw data I've listed 2 example Dept (Dept1A and Dept2A). From column D, you can assume the pattern continues like Dept1ALevel1, Hour - Dept1ALevel1, Comment - Dept1ALevel1 and so forth up to Dept20ALevel20.

    I've also attached my desired result in my excel.

    If someone knows how do i translate my power query commands regardless if the headers change that would be very helpful.

    Thank you
    Attached Files Attached Files

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

    Re: Pivot columns and Extract without PowerQuery

    In what way do the headers change? Give an example.

    Doesn't this M Code work?

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by AliGW; 04-08-2024 at 01:13 AM. Reason: Workbook updated.
    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. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert
    Join Date
    12-09-2014
    Location
    Trakai, Lithuania
    MS-Off Ver
    2016
    Posts
    1,437

    Re: Pivot columns and Extract without PowerQuery

    Power Query
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Czeslaw; 04-08-2024 at 01:15 AM.

  4. #4
    Forum Contributor
    Join Date
    12-03-2020
    Location
    australia
    MS-Off Ver
    365
    Posts
    112

    Re: Pivot columns and Extract without PowerQuery

    So from the raw data you can see the headers are "Dept1ALevel1", it might change to "Org1ALevel1" or "Div66A" etc but the pattern remains the same i.e there will always be 3 columns repeating and I need the first two (ignore the last one with the comment)
    Last edited by AliGW; 04-08-2024 at 01:31 AM. Reason: Please don't quote unnecessarily - use the Quick Reply button instead.

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

    Re: Pivot columns and Extract without PowerQuery

    OK - so did you test drive my solution?

    If it doesn't work, then provide more realistic sample data.

  6. #6
    Forum Contributor
    Join Date
    12-03-2020
    Location
    australia
    MS-Off Ver
    365
    Posts
    112

    Re: Pivot columns and Extract without PowerQuery

    See the problem with power query is the moment I have a new data that follows the same pattern it break down. The moment I modify the previous header to say Level1A to Level3A it stops working hence why I needed a formula instead of doing it via power query
    Last edited by AliGW; 04-08-2024 at 01:35 AM. Reason: Please don't quote unnecessarily - use the Quick Reply button instead.

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,924

    Re: Pivot columns and Extract without PowerQuery

    Does MY solution stop working?

    Provide more realistic sample data, please.

    And please stop quoting unnecessarily!

  8. #8
    Forum Contributor
    Join Date
    12-03-2020
    Location
    australia
    MS-Off Ver
    365
    Posts
    112

    Re: Pivot columns and Extract without PowerQuery

    @AliGW, your solution did not work. That is an exact copy of my dataset (minus the confidential info).

    When you run it from your end, consider changing the Header in column D "Dept1ALevel1" to "Dept1ALevel11", it fails because the data set that I always get is different in header but the pattern remain the same i.e the first 3 columns are "Name", "Hours" and "Comment", but then the next columns come in groups of 3s.

    First one being Dept or Org or Div what ever, Followed by Hours - blah blah and then Comment, this repeats over and over in groups of 3s.

    I only want the first two pivoted automatically without having to do it via power query every time.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,924

    Re: Pivot columns and Extract without PowerQuery

    OK. Have a look at the other solution offered.

  10. #10
    Forum Contributor
    Join Date
    12-03-2020
    Location
    australia
    MS-Off Ver
    365
    Posts
    112

    Re: Pivot columns and Extract without PowerQuery

    I did have a look at the other solution, it runs into the same problem. I can do it using power query but it fails once the dataset changes with different headers. Power query hard codes the headers which i don't want... i want to reference the columns without hard coding the header if that makes sense. Thank you for looking into this problem.

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,924

    Re: Pivot columns and Extract without PowerQuery

    Ok - so what's the maximum set of three that we could be dealing with? You still need to provide more realistic data, because at the moment, there's a clear pattern in those headers. Members will use the sample data provided to work out a solution for you, so please make it realistic.

  12. #12
    Forum Contributor
    Join Date
    12-03-2020
    Location
    australia
    MS-Off Ver
    365
    Posts
    112

    Re: Pivot columns and Extract without PowerQuery

    There will be 16 set of 3's.

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,924

    Re: Pivot columns and Extract without PowerQuery

    And the minimum? Will that be one set? Or two?

    I am waiting for a more realistic sample set of data that doesn't have a pattern with those headers.

+ 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] PowerQuery/Pivot missing data
    By jomili in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 08-19-2022, 11:27 AM
  2. Help with powerquery to extract JSON parameter values from the data
    By chandramouliarun in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-23-2021, 03:28 AM
  3. Help with Powerquery to extract feedback values in the input data
    By chandramouliarun in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-08-2021, 01:18 AM
  4. [SOLVED] Unable to extract data from web pages, using Powerquery, correctly onto an Excel sheet
    By Doofus1 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-04-2021, 10:50 PM
  5. Cannot extract Powerquery data into designated cell from website
    By Doofus1 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-04-2021, 04:22 AM
  6. [SOLVED] Powerquery Help to help extract values from JSON data
    By chandramouliarun in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-23-2020, 01:25 AM
  7. [SOLVED] Unable to make Powerquery extract data correctly onto an Excel sheet
    By Doofus1 in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 11-21-2020, 04:24 PM

Tags for this Thread

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