Bonjour à tous de nouveau !
Code de la requête :
let
Source = Excel.CurrentWorkbook(){[Name="t_BDD"]}[Content],
TypeDate = Table.TransformColumnTypes(Source,{{"Date", type date}}),
// Liste unique des OP
List_OP = List.Distinct(TypeDate[OP]),
// Elaboration table complète : Dates et OP
TblDates = Table.ExpandListColumn(
Table.AddColumn(
Table.FromList(
let
DateMin = List.Min(TypeDate[Date]),
DateMax = List.Max(TypeDate[Date]),
LD= List.Dates(DateMin, Duration.Days(DateMax-DateMin)+1, Duration.From(1))
in
LD,
Splitter.SplitByNothing(),
{"Dates"},
null,
ExtraValues.Error
),
"OP",
each List_OP
),
"OP"
),
// Sommation quotidienne des temps
GroupBy = Table.Group(TypeDate, {"Date", "OP"}, {{"TimeIn", each List.Sum([Time]), type number}}),
// Fusion avec la table complète
Fusion = Table.NestedJoin(TblDates, {"Dates", "OP"}, GroupBy, {"Date", "OP"}, "Lignes groupées", JoinKind.LeftOuter),
Expand = Table.ExpandTableColumn(Fusion, "Lignes groupées", {"TimeIn"}, {"TimeIn"}),
// Calcul du temps OUT
Ajt_TimeOut = Table.AddColumn(Expand, "TimeOut", each 8- ([TimeIn] ?? 0)),
// Unpivot pour le rapport de TCD
Unpivot = Table.UnpivotOtherColumns(Ajt_TimeOut, {"Dates", "OP"}, "TypeTime", "Time"),
TypeDates = Table.TransformColumnTypes(Unpivot,{{"Dates", type date}})
in
TypeDates