Back to All DAX Concepts
Advanced

DAX RANKX Function

Dynamic ranking of customers, products, and categories.

Syntax Definition:
RANKX( Table, Expression, [Value], [Order], [Ties] )

Overview

RANKX computes the rank of an expression across a given table or set of dimension keys in the current visual context.

Architectural Deep Dive

To rank correctly in Power BI, you must supply an unfiltered table (typically wrapped in ALL) as argument 1, and the measure to rank by as argument 2. This ensures the current row coordinate can be evaluated against the entire population.

Canonical Pattern Example:

Customer Revenue Rank = 
RANKX(
    ALL(Customers),
    [Total Revenue],
    ,
    DESC,
    Dense
)

Common Anti-Patterns & Mistakes to Avoid

  • Passing Customers without ALL()—the measure will evaluate only the single filtered customer and return 1 for everybody!
  • Forgetting to handle ties (Skip vs Dense ranking).
Interactive Challenge

Put DAX RANKX Function into practice

Solve "Customer Rank by Revenue with RANKX" in our interactive Monaco editor with live dataset verification.