- let
- 源 = Excel.CurrentWorkbook(){[Name = "表1"]}[Content],
- 分组的行 = Table.Group(
- 源,
- "编号",
- {
- "tb",
- each [
- a = Table.Sort([[日期], [结果]], each [日期]),
- b = List.Repeat(Table.ColumnNames(a), Table.RowCount(a)),
- c = List.Transform({1, 0}, each List.Alternate(b, 1, 1, _)),
- d = List.TransformMany(c, each {1 .. List.Count(_)}, (x, y) => x{y - 1} & Text.From(y)),
- e = Table.Transpose(Table.FromValue(List.Combine(Table.ToColumns(a))), d)
- ][e]
- }
- ),
- 结果 = [
- a = List.Transform(分组的行[tb], each Table.ColumnNames(_)),
- b = List.Max(List.Transform(a, each List.Count(_))),
- c = List.Select(a, each List.Count(_) = b),
- d = Table.ExpandTableColumn(分组的行, "tb", c{0})
- ][d]
- in
- 结果
复制代码 |