Table.AggregateTableColumn

Syntax

Table.AggregateTableColumn(
    table as table,
    column as text,
    aggregations as list
) as table

About

将 [column] 中的table表聚合为包含表的聚合值的多个列。 aggregations 用于指定要聚合的表的列、要应用于表的聚合函数以生成其值以及要创建的聚合列的名称。

示例 1

将表中{[t = {[a=1, b=2, c=3], [a=2,b=4,c=6]}, b = 2]}的表列[t]聚合为[t.a]总和、最小值和最大值[t.b]以及值计数。[t.a]

用法

Table.AggregateTableColumn(
    Table.FromRecords(
        {
            [
                t = Table.FromRecords({
                    [a = 1, b = 2, c = 3],
                    [a = 2, b = 4, c = 6]
                }),
                b = 2
            ]
        },
        type table [t = table [a = number, b = number, c = number], b = number]
    ),
    "t",
    {
        {"a", List.Sum, "sum of t.a"},
        {"b", List.Min, "min of t.b"},
        {"b", List.Max, "max of t.b"},
        {"a", List.Count, "count of t.a"}
    }
)

输出

Table.FromRecords({[#"sum of t.a" = 3, #"min of t.b" = 2, #"max of t.b" = 4, #"count of t.a" = 2, b = 2]})