跳到主要内容

Table.AggregateTableColumn

将多个表的一列聚合到包含表中的多列。

Syntax

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

Remarks

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

Examples

Example #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"}
}
)

Result:

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

Category

Table.Transformation