Overview
RANKX combined with ALL, ALLEXCEPT, and ISINSCOPE gives you static global ranks, ranks within a category, and dynamic ranks that respond when users drill into a hierarchy.
RANKX patterns for global, segmented, and interactive ranks.
On this page
RANKX combined with ALL, ALLEXCEPT, and ISINSCOPE gives you static global ranks, ranks within a category, and dynamic ranks that respond when users drill into a hierarchy.
Ranks every product against all products, ignoring visual row filters on Product:
Global Product Rank =
RANKX(
ALL ( Product[ProductName] ),
[Total Sales],
,
DESC,
Dense
)Category Product Rank =
RANKX(
ALLEXCEPT ( Product, Product[Category] ),
[Total Sales],
,
DESC,
Dense
)Electronics products rank 1, 2, 3… only among other Electronics; Furniture has its own 1, 2, 3 sequence.
Dynamic Product Rank =
IF(
ISINSCOPE ( Product[ProductName] ),
[Category Product Rank],
[Global Product Rank]
)Top 3 Products =
IF(
[Global Product Rank] <= 3,
[Total Sales],
BLANK()
)Use in a bar chart with Product on axis—only the top three bars appear. Combine with a Category slicer to see top 3 within a segment by swapping [Global Product Rank] for [Category Product Rank] in the condition.
Ranking Patterns at a Glance
| Pattern | Filter Modifier | Rank Scope | When to Use |
|---|---|---|---|
| Static / Global | ALL ( Product[ProductName] ) | All products in model | Executive leaderboard, Top N |
| Category / Segment | ALLEXCEPT ( Product, Product[Category] ) | Products in current category | Best sellers per category |
| Dynamic | ISINSCOPE ( Product[ProductName] ) | Switches by hierarchy level | One matrix with drill-down |
| Top N display | IF ( Rank <= 3, [Sales], BLANK() ) | Hides non-top rows | Focused bar charts |