Rank products by sales with RANKX

Give every product its place in the leaderboard — and learn why RANKX needs ALL to compare a row against its rivals.

You will learn to

  • Rank items by a measure with RANKX
  • Explain why the ranking table needs ALL
  • Choose descending or ascending order

How it works

`RANKX(table, expression)` evaluates the expression for every row of the table, then reports where the **current** cell’s value falls in that list. The highest value is rank 1 by default (descending).

The table is the list of competitors. In a matrix row for Road-150, the filter context only contains Road-150. If you rank over `Product`, the competition is a list of one, and every product wins. `ALL(Product)` removes that filter so each product is compared against all twelve.

The expression must be a measure such as `[Total Sales]`, so context transition evaluates it once per competitor. To rank the smallest value first, pass the value again and add `ASC`: `RANKX(ALL(Product), [Total Sales], [Total Sales], ASC)`.

Practice it hands-on with a real data model and a live report that updates as you type.

Price Rank = RANKX(ALL(Product), CALCULATE(MAX(Product[Price])))