DAX / PowerPivot三个时段的重叠

我试图计算一个事件的有效持续时间,计算列如下:[事件总时间] – [不在办公室的时间重叠事件] – [在办公时间系统停机时间],我无法弄清楚这是如何做到的

OfficeHoursTable:

date - office hours start time - office hours end time - is working day 01/01/2017 - 08:00 am - 08:00 pm - 0 02/01/2017 - 08:00 am - 08:00 pm - 1 ... 09/01/2017 - 08:00 am - 08:00 pm - 1 10/01/2017 - 08:00 am - 08:00 pm - 1 11/01/2017 - 08:00 am - 08:00 pm - 1 ... 

SystemDowntimeTable:

 date - system downtime start time - system downtime end time 01/01/2017 - 08:17 am - 9:43 am 10/01/2017 - 7:00 pm - 8:00 pm 

EventsTable:

 EventID - start datetime - end datetime - effective duration 1 - 01/01/2017 7:40 am - 01/01/2017 8:40 am - 0; Comment: 0 is because though there was a dowtime of the system overlapping this event, the event itself was during non working day 2 - 09/01/2017 7:40 am - 11/01/2017 11:00 am - 24; Comment: [total duration of event] - [out of office hours overlapping the event] - [system downtime during office hours] = 24 hours 3 - 

我想这个有效的持续时间计算列在EventsTable中

你可以想象有很多重叠和时间智能正在进行,我不能把我的头围绕这个。

我正在运行Excel 2013的PowerPivot