DAX function
RANKX — DAX function reference
Rank rows by an expression.
Syntax
dax
RANKX(<table>, <expression>, [<value>], [<order>], [<ties>])
Examples
dax
RANKX(ALL(Product), [Total Sales])
→ A rank
dax
RANKX(ALLSELECTED(Product), [Total Sales], , DESC)
→ Rank among visible products, respecting slicers
The ties argument controls whether tied values consume multiple rank numbers (SKIP, the default) or share the same rank without a gap (DENSE).
dax
RANKX(ALL(Product), [Total Sales], , ASC, DENSE)
→ Ascending, dense ranking with no gaps after ties
Common mistakes & gotchas
- Wrap the first argument in ALL or ALLSELECTED, or every row ranks 1.
- Wrapping the first argument in ALL/ALLSELECTED is required — without it, RANKX evaluates the expression across a table already filtered down to the current row’s context, so every row ranks 1.
- The default tie-handling is SKIP: two products tied for 1st both show rank 1, but the next product jumps to rank 3, not 2 — use DENSE for consecutive ranks instead.
Related DAX functions
From Iterators & variables