Table.AddRankColumn
语法
Table.AddRankColumn(table as table, newColumnName as text, comparisonCriteria as any, optional options as nullable record) as table
关于
将名为 newColumnName
的列追加到 table
,并使用由 comparisonCriteria
描述的一个或多个其他列进行排名。 高级用户可以使用 options
中的 RankKind
选项来选择更具针对性的排名方法。
示例 1
向表中添加名为“RevenueRank”的列,以便对“Revenue”列进行从高到低的排名。
使用情况
Table.AddRankColumn(
Table.FromRecords({
[CustomerID = 1, Name = "Bob", Revenue = 200],
[CustomerID = 2, Name = "Jim", Revenue = 100],
[CustomerID = 3, Name = "Paul", Revenue = 200],
[CustomerID = 4, Name = "Ringo", Revenue = 50]
}),
"RevenueRank",
{"Revenue", Order.Descending},
[RankKind = RankKind.Competition]
)
输出
Table.FromRecords({
[CustomerID = 1, Name = "Bob", Revenue = 200, RevenueRank = 1],
[CustomerID = 3, Name = "Paul", Revenue = 200, RevenueRank = 1],
[CustomerID = 2, Name = "Jim", Revenue = 100, RevenueRank = 3],
[CustomerID = 4, Name = "Ringo", Revenue = 50, RevenueRank = 4]
})