Downloads
DAXRanking and windowsAdvanced

RANK

A newer DAX function that ranks items in an ordered set of rows. Its exact arguments depend on the version you use.

Syntax
RANK(...) (argument list depends on your version. Check the current Microsoft DAX reference before you use it.)

Returns: A whole number (the rank).

What it does

RANK is one of the newer DAX functions that work on an ordered set of rows. It belongs to the same family as WINDOW, OFFSET, INDEX and ROWNUMBER. It gives each item a position based on an ordering you choose, such as sales from highest to lowest. For ranking in a model today, RANKX is the established function with well-known arguments, and most finance models use it.

This page does not show RANK code, because the exact argument list could not be confirmed from the reference material available for this page. Check the Microsoft DAX reference for your version before you depend on RANK.

Syntax and arguments

The arguments depend on the version. Read the current documentation for the order to use, which rows form the set, and how ties are handled.

Example

The same question, answered with the established function: the rank of each product by sales, among the products the user has selected.

Product Rank =
RANKX (
    ALLSELECTED ( Product[ProductName] ),
    [Total Sales],
    ,
    DESC,
    DENSE
)

In a table with one row per product, each row shows its position among the selected products. The same business question can be answered with RANK once you have confirmed its arguments for your version.

Things to watch

In business terms

Ranking vendors by spend, customers by receivables, or branches by margin. The business use is the same as for RANKX: a position that reviewers can read at a glance.

Related functions

All DAX functions · View as Markdown · DAX fundamentals