- //Unnamed
- let
- 源 = Excel.CurrentWorkbook(){[Name = "表1"]}[Content],
- 更改的类型 = Table.TransformColumnTypes(
- 源,
- {
- {"酒店", type text},
- {"技师姓名", type text},
- {"科目A", Int64.Type},
- {"科目B", Int64.Type},
- {"科目C", Int64.Type}
- }
- ),
- 分组的行 = Table.Group(
- 更改的类型,
- {"酒店"},
- {{"data", each Table.AddColumn(_, "小计", (x) => List.Sum(List.Skip(Record.ToList(x), 2)))}}
- ),
- 自定义1 = Table.TransformColumns(
- Table.SelectRows(分组的行, each not List.Contains([data][小计], 18, (x, y) => x < y)),
- {
- {
- "data",
- each Table.SelectRows(
- Table.AddRankColumn(_, "rank", {{"小计", 1}}, [RankKind = 1]),
- each [rank] <= 3
- )
- }
- }
- ),
- 自定义2 = Table.TransformColumns(
- 自定义1,
- {
- {
- "data",
- each Table.FromRows(
- {
- [
- a = Table.ToColumns(_),
- b = Text.Combine(a{1}, ","),
- c = List.Accumulate(
- {2 .. 4},
- {},
- (x, y) => x & {Number.Round(List.Sum(a{y}) / List.Count(a{y}), 2)}
- ),
- d = {b} & c
- ][d]
- },
- {"技师", "科目A", "科目B", "科目C"}
- )
- }
- }
- ),
- #"展开的“data”" = Table.ExpandTableColumn(
- 自定义2,
- "data",
- {"技师", "科目A", "科目B", "科目C"},
- {"技师", "科目A", "科目B", "科目C"}
- )
- in
- #"展开的“data”"
复制代码 |