Skip to content

Latest commit

 

History

History
46 lines (36 loc) · 1.37 KB

table-addrankcolumn.md

File metadata and controls

46 lines (36 loc) · 1.37 KB
description title
Learn more about: Table.AddRankColumn
Table.AddRankColumn

Table.AddRankColumn

Syntax

Table.AddRankColumn(table as table, newColumnName as text, comparisonCriteria as any, optional options as nullable record) as table

About

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.

Example 1

Add a column named RevenueRank to the table which ranks the Revenue column from highest to lowest.

Usage

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]
)

Output

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]
})