Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Linking TimeStamp to Value between Dates in Seperate Table

Hello,   I'm new to Power Query and DAX, trying to recreate some reports in it to improve efficiency in their generation.  Having some trouble mimicking a few calculations performed in Excel otherw...
  • Stachu's avatar
    Stachu
    7 years ago

    this would work in M

    let
        Source = MASTER3_TIMETRACKING,
        #"Merged Queries" = Table.NestedJoin(Source, {"mrTIMEUSER"}, tblEmployeeHistory, {"EmployeeID"}, "Custom", JoinKind.LeftOuter),
        #"Expanded Changed Type" = Table.ExpandTableColumn(#"Merged Queries", "Custom", {"Role", "Start Date", "End Date"}, {"Role", "Start Date", "End Date"}),
        #"Filtered Rows" = Table.SelectRows(#"Expanded Changed Type", each [Start Date] <= [mrTIMEDATE] and [End Date] >= [mrTIMEDATE]),
        #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Start Date", "End Date"})
    in
        #"Removed Columns"

    idea is following:

     

    1) you merge the queries based on EmployeeID (only)
    2) you expand the [Role], [Start Date] and [End Date] (at this point you will have more rows than in the beginning)

    3) you filter the dates based on the [mrTIMEDATE] (you should have the same number of rows as in 1) now)
    4) you remove unnecessary columns