Table.AddRankColumn
Appends a column with the ranking of one or more other columns.
Syntax
Table.AddRankColumn(
table as table,
newColumnName as text,
comparisonCriteria as any,
optional options as record
) as table
Remarks
Appends a column named newColumnName
to the table
with the ranking of one or more other columns described by comparisonCriteria
.The RankKind option in options
can be used by advanced users to pick a more-specific ranking method.
Examples
Example #1
Add a column named "RevenueRank" to the table which ranks the "Revenue" column from highest to lowest.
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]
)
Result:
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]
})
Category
Table.Ordering