Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Conditional Join on "Line Name" and Data Range

Hello:  I am trying to join two tables by "Line Name" with table one filtering the data in table two by date range such that table table two to only show data WHERE "timestamp" falls within the "SHI...
  • v-frfei-msft's avatar
    6 years ago

    Hi Anonymous ,

     

    We can merge tables based on Line name and filter the table based on the new custom column 

     

    let
        Source = Table.NestedJoin(Shifts, {"LINE NAME"}, #"Machine State data", {"Line Name"}, "Machine State data", JoinKind.LeftOuter),
        #"Expanded Machine State data" = Table.ExpandTableColumn(Source, "Machine State data", {"timestamp"}, {"Machine State data.timestamp"}),
        #"Added Custom" = Table.AddColumn(#"Expanded Machine State data", "Custom", each [Machine State data.timestamp]>=[SHIFT PERIOD START] and[Machine State data.timestamp]<=[SHIFT PERIOD END]),
        #"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Custom] <> false))
    in
        #"Filtered Rows"

     

     Pbix as attached.