Forum Discussion
RvdC
6 years agoFrequent Visitor
Calculating with DAX the total Interruption Time with overlapping intervals
I have a challenge with this case: There is a technical installation which produces products on order. Only one order at the time. Each order has a unique ID. It starts with the starts order acti...
- Anonymous6 years ago
RvdC ,
Hey thanks for pointing that out.
i had missed checking a gap in between interupption time.
Hope this works.
RvdC ,
Thanks, There is a gap of 10 mins in between. I did not notice that.
Hope this works.
Calculated Columns
End of Previous InteruptionID = IF (Table4[Activity] = "Start Interruption", CALCULATE(MAX(Table4[Date/Time End]),FILTER(ALLEXCEPT(Table4,Table4[Order_ID]), Table4[Interuption ID]<EARLIER(Table4[Interuption ID]) && Table4[Activity] = "Start Interruption")))Gaps in Between = IF ( Table4[End of Previous InteruptionID] < Table4[Date/Time], DATEDIFF(Table4[End of Previous InteruptionID], Table4[Date/Time],MINUTE))Measure
Interuption Time (Orders) =var _addgaps = CALCULATE(SUM(Table4[Gaps in Between]), ALLEXCEPT(Table4, Table4[Order_ID]))var _StartTime = CALCULATE(MIN(Table4[Date/Time]),Filter(ALLEXCEPT(Table4,Table4[Order_ID]), Table4[Activity] = "Start Interruption"))var _EndTime = CALCULATE(MAX(Table4[Date/Time End]),Filter(ALLEXCEPT(Table4,Table4[Order_ID]), Table4[Activity] = "Start Interruption"))returnDATEDIFF(_StartTime,_EndTime,MINUTE) - _addgapsRegards,Harsh NathaniDid I answer your question? Mark my post as a solution! Appreciate with a Kudos!!
Anonymous
6 years agoNot applicable
RvdC ,
Hey thanks for pointing that out.
i had missed checking a gap in between interupption time.
Hope this works.
RvdC ,
Thanks, There is a gap of 10 mins in between. I did not notice that.
Hope this works.
Calculated Columns
End of Previous InteruptionID = IF (Table4[Activity] = "Start Interruption", CALCULATE(MAX(Table4[Date/Time End]),FILTER(ALLEXCEPT(Table4,Table4[Order_ID]), Table4[Interuption ID]<EARLIER(Table4[Interuption ID]) && Table4[Activity] = "Start Interruption")))
Gaps in Between = IF ( Table4[End of Previous InteruptionID] < Table4[Date/Time], DATEDIFF(Table4[End of Previous InteruptionID], Table4[Date/Time],MINUTE))
Measure
Interuption Time (Orders) =
var _addgaps = CALCULATE(SUM(Table4[Gaps in Between]), ALLEXCEPT(Table4, Table4[Order_ID]))
var _StartTime = CALCULATE(MIN(Table4[Date/Time]),Filter(ALLEXCEPT(Table4,Table4[Order_ID]), Table4[Activity] = "Start Interruption"))
var _EndTime = CALCULATE(MAX(Table4[Date/Time End]),Filter(ALLEXCEPT(Table4,Table4[Order_ID]), Table4[Activity] = "Start Interruption"))
return
DATEDIFF(_StartTime,_EndTime,MINUTE) - _addgaps
Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!!
RvdC
6 years agoFrequent Visitor
Thanks a lot for your help! All works fine for me.
Best,
Rob