Forum Discussion

Tgilchrist's avatar
Tgilchrist
Frequent Visitor
6 years ago
Solved

Joining two tables where TABLE1.Datetime is between TABLE2.StartDatetime and TABLE2.EndDatetime

I have two tables TABLE1 and TABLE2. Currently there are no relationships between them but TABLE1 contains the Datetime of an event and TABLE2 contains a StartDatetime and EndDatetime for each shift...
  • edhans's avatar
    6 years ago

    See if this helps. It returns this in Power Query:

    To get this result, add a column to your Table 1 with this formula:

    Table.SelectRows(
        Table2,
        (Ranges) => ([Datetime] >= Ranges[StartDateTime])
                    and
                    ([Datetime] <= Ranges[EndDateTime])
    
    )

    That will return a nested table from Table2 that has only the records in that range.

    Then just expand that added custom column.

     

    See this file for full details.