let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
TypesModifiés = Table.TransformColumnTypes(Source,{{"Début Intervention", type datetime}, {"Fin Intervention", type datetime}}),
AjoutColonneDépassement = Table.AddColumn(TypesModifiés, "Dépassement", each
let
interventionPeriod = [From=[Début Intervention], To=[Fin Intervention]],
fnIntersect = (P1 as record, P2 as record) as duration => List.Max({#duration(0,0,0,0), List.Min({P1[To], P2[To]})-List.Max({P1[From], P2[From]})}),
daysList = {Number.From(Date.From([Début Intervention])) .. Number.From(Date.From([Fin Intervention]))},
periodsList = List.Combine(List.Transform(daysList, each {[From=DateTime.From(_)+#duration(0,0,0,0), To=DateTime.From(_)+#duration(0,7,0,0)], [From=DateTime.From(_)+#duration(0,19,0,0), To=DateTime.From(_)+#duration(0,24,0,0)]})),
intersectList = List.Transform(periodsList, each fnIntersect(interventionPeriod, _))
in
List.Sum(intersectList), type duration)
in
AjoutColonneDépassement