1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| let
Source = Excel.CurrentWorkbook(){[Name="Tab_ListeArrets"]}[Content],
#"Type modifié" = Table.TransformColumnTypes(Source,{{"Matricule", type text}, {"Prénom", type text}, {"Nom", type text}, {"Type", type text}, {"Date", type date}}),
#"Lignes triées" = Table.Sort(#"Type modifié",{{"Matricule", Order.Ascending}, {"Date", Order.Ascending}, {"Type", Order.Ascending}}),
#"Index ajouté" = Table.AddIndexColumn(#"Lignes triées", "Index0", 0, 1, Int64.Type),
#"Index ajouté1" = Table.AddIndexColumn(#"Index ajouté", "Index1", 1, 1, Int64.Type),
#"Requêtes fusionnées" = Table.NestedJoin(#"Index ajouté1", {"Index1"}, #"Index ajouté1", {"Index0"}, "Index ajouté1", JoinKind.LeftOuter),
#"Index ajouté1 développé" = Table.ExpandTableColumn(#"Requêtes fusionnées", "Index ajouté1", {"Matricule", "Type", "Date"}, {"Matricule.1", "Type.1", "Date.1"}),
#"Personnalisée ajoutée" = Table.AddColumn(#"Index ajouté1 développé", "Date fin", each if [Matricule]=[Matricule.1] and [Type]=[Type.1] and Date.AddDays([Date],1)=[Date.1] then null else [Date], type date),
#"Rempli vers le haut" = Table.FillUp(#"Personnalisée ajoutée",{"Date fin"}),
#"Personnalisée ajoutée1" = Table.AddColumn(#"Rempli vers le haut", "JO", each if Date.DayOfWeek([Date])+1>5 then 0 else 1),
#"Lignes groupées" = Table.Group(#"Personnalisée ajoutée1", {"Matricule", "Prénom", "Nom", "Type", "Date fin"}, {{"Date début", each List.Min([Date]), type nullable date}, {"Nb Jours", each List.Sum([JO]), type number}}),
#"Colonnes permutées" = Table.ReorderColumns(#"Lignes groupées",{"Matricule", "Prénom", "Nom", "Type", "Date début", "Date fin", "Nb Jours"}),
#"Lignes triées1" = Table.Sort(#"Colonnes permutées",{{"Date début", Order.Ascending}})
in
#"Lignes triées1" |