看看是不是你要的效果!!!
- let
- fn = (lst)=> List.Transform(
- {1..List.Count(List.Range(lst,1))},each List.Min({
- List.Max(
- {List.Accumulate(List.Range(lst,1,_), 0, (state, current) => state + current)-lst{0},0}
- ),List.Range(lst,1){_-1}})
- ),
- Source = Table.TransformColumns(Table.AddIndexColumn(Excel.CurrentWorkbook(){[Name="Table2"]}[Content],"Lst"),{"Lst",each List.Skip(Table.ToRows(Excel.CurrentWorkbook(){[Name="Table2"]}[Content]){_},1)}),
- Lst = Table.TransformColumns(Source,{"Lst",each Record.FromList(fn(_),Name)}),
- B = Table.RemoveColumns(Lst,{"W1", "W2", "W3", "W4", "W5"}),
- Result = Table.ExpandRecordColumn(B, "Lst", {"W1", "W2", "W3", "W4", "W5"}, {"W1", "W2", "W3", "W4", "W5"}),
- Name = List.RemoveLastN(List.Range(Table.ColumnNames(Source),2),1)
- in
- Result
复制代码 |