let
Source = Excel.CurrentWorkbook(){[Name="tSource"]}[Content],
Types = Table.TransformColumnTypes(Source,{{"date", type date}, {"Euro", type number}}),
GroupBy = Table.Group(
Types,
{"nume"},
{
{"Détails", each _, type table [jour=text, comp=text, comp1=any, date=nullable date, libe=text, nume=nullable text, Sens=text, Euro=nullable number, anal=nullable text, lett=text]},
{"Taux", each let tTva= List.Sum(Table.SelectRows(_, each Text.StartsWith([comp],"4"))[Euro]) in tTva/(List.Sum([Euro])-tTva)}
}),
Expand = Table.ExpandTableColumn(GroupBy, "Détails", List.Difference(Table.ColumnNames(Source),{"nume"})),
ValRempl = Table.ReplaceValue(Expand,each [Taux],each if Text.StartsWith([comp],"4") then [Taux] else null,Replacer.ReplaceValue,{"Taux"}),
RéorgCol = Table.ReorderColumns(ValRempl,Table.ColumnNames(Source)&{"Taux"})
in
RéorgCol