+ Reply to Thread
Results 1 to 3 of 3

Power Query grouping of related items to find earliest datetime

  1. #1
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Power Query grouping of related items to find earliest datetime

    Hi,

    I have a table as can be seen in the attached workbook. I am trying to use Power Query to group those items from column A and column B which have an unbroken relationship through date/timestamps, find the earliest related date/timestamp, and copy that date/timestamp to each row for the group in a new column.

    The relationship between grouped items from column A and column B which belong together is as such:

    1. The row with newest date/timestamp has the value "false" in column C, along with the newest date/timestamp in column D.

    2. The immediate preceding related row has the value "true" in column C, and the same date/timestamp as the succeeding (item 1.) related row, in its column E. This row has an earlier date/timestamp in its column D.

    3. The predecessor to the above described row (in 2.) also has the value "true" in column C, and the same date/timestamp in its column E that item 2. has in its column D. Item 3 then has an earlier date/timestamp in its column D.

    4. Etc. until there are no more "linked" rows with value "true" in column C. Also, most of the rows don't have any other related rows, but will be "standalone" rows with value "false" in column C (and on occasion the value "true").

    I am trying to produce a column with the results seen in column I.

    NB: The information in columns F, G and H are for clarifying the relationships only, and shall not be used to achieve the result. These columns will not be present, normally.

    Does anybody see how to solve this with Power Query?

    Best regards,
    Marbleking
    Attached Files Attached Files
    Last edited by Marbleking; 11-08-2021 at 05:30 AM.

  2. #2
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,562

    Re: Power Query grouping of related items to find earliest datetime

    As this has been sitting a few days with no response, I'll offer the following formula based proposal:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Note that the formula doesn't return the expected results for rows 20, 23 and 27, however given the criteria above I feel that the formula output may be correct.
    Let us know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  3. #3
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Power Query grouping of related items to find earliest datetime

    Hi JeteMC,

    Thanks for the formula! I requested a formula solution a while ago in the commercial forum and got a solution from samba_ravi that solved the conundrum, please see attached workbook containing two variants of this solution.

    Now I hope that there's an efficient way to perform this trick in Power Query.

    Regards,
    Marbleking
    Attached Files Attached Files
    Last edited by Marbleking; 11-12-2021 at 03:57 AM.

+ 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. Power query grouping - conditional to data across several columns??...
    By sunnyspirit in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-01-2021, 11:53 AM
  2. Data grouping in Power Query
    By hudson andrew in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-12-2020, 10:44 AM
  3. Replies: 10
    Last Post: 06-25-2020, 12:19 AM
  4. Need a solution for power query related work
    By jones143 in forum Excel General
    Replies: 0
    Last Post: 05-16-2020, 02:32 PM
  5. [SOLVED] Get and Transform (Power Query) - Grouping numbers into bands/buckets
    By TheNewUnion in forum Excel General
    Replies: 2
    Last Post: 03-12-2019, 05:37 AM
  6. Help with grouping in power query
    By stephme55 in forum Excel General
    Replies: 1
    Last Post: 07-26-2016, 03:09 PM
  7. Help on grouping items in a query
    By ExcelFailure in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-09-2013, 02:54 AM

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