Forum Discussion
igonzalezb
Helper I
5 years agoFind 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...
- 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)
lbendlin
Super User
5 years agoYou may want to provide more details. What if worker shifts overlap and the event at the station happened during that time?
igonzalezb
Helper I
5 years agolbendlin Hello. As stated in the post, there is no overlap. Let's assume there are no edge cases.