Forum Discussion

igonzalezb's avatar
igonzalezb
Helper I
5 years ago
Solved

Find corresponding worker based on shift begining and end datetimes

I have table A of events: Event ID    Station ID    Timestamp (datatime)    10 A   20 B   30 A     And I have table B of workers and their shifts: Station ID      Worke...
  • lbendlin's avatar
    lbendlin
    5 years ago

    I would keep the tables disconnected, or - if you must - create a Stations dimensional table.

     

    Regardless, the calculated column in the Events table would just reference the  entire workers_shifts table with the appropriate filters

     

     

    Meta Code:

     

    Emp = 
    var s = selectedvalue([Station ID])

    var d = selectedvalue([Timestamp])

    Return calculate(max(workers[Worker ID]),workers[Station ID]=s,workers[Shift start]<=d,workers[Shift end]>=d)