This guide gives UK SME teams a practical implementation path: start with the business question, check the data or workflow, build the smallest useful version, then document what has changed.
This guide gives UK SME teams a practical implementation path: start with the business question, check the data or workflow, build the smallest useful version, then document what has changed.
This guide gives UK SME teams a practical implementation path: start with the business question, check the data or workflow, build the smallest useful version, then document what has changed.
Book a data risk call View all services Power BI guide Home / Guides / Power BIRank products, customers or sites inside each Power BI category with RANKX while keeping filter context under control.
2026-06-16 9 min read min read Digital Adaption On this pageRANKX is powerful, but it is also one of the easiest DAX functions to make confusing. Ranking within category means the measure must remove the item filter while keeping the category filter. For broader reporting repair work, see the Power BI consultancy and ERP reporting analytics pages.
Practical answerWrite a base measure, use RANKX over the item list inside the current category, and use ALLEXCEPT or a carefully scoped table expression so category filters remain active.
Decide what is being ranked and inside which category. For example, products within product group, customers within region, or sites within business unit.
If the category comes from a different table, check the relationship path. Ranking problems often start with a model that cannot filter the item table cleanly.
The measure below ranks products inside the current category by sales. ALLEXCEPT keeps the category context while removing the individual product filter for the ranking set.
In some models, ALLSELECTED is better because it respects user selections. Test both against the expected business behaviour.
Sales Amount =
SUM ( Sales[Net Amount] )
Product Rank Within Category =
IF (
ISBLANK ( [Sales Amount] ),
BLANK (),
RANKX (
ALLEXCEPT ( Product, Product[Category] ),
[Sales Amount],
,
DESC,
Dense
)
)
Dense ranking gives tied items the same rank and uses the next available rank without a gap. Skip ranking leaves a gap after ties. Neither is universally right; choose the one users expect.
Blank values should often stay blank rather than ranking last, especially when the visual is used for performance management.
Using ALL(Product) ranks across every product unless the category filter is reapplied.
Most business ranking should be based on a measure so it respects filters, dates and slicers.
Blank items can appear with misleading ranks unless the measure returns blank deliberately.
Digital Adaption helps UK SMEs rebuild trusted Power BI, ERP and operational reporting after migrations, ownership gaps and model drift.
Use ALLEXCEPT when the category context must be preserved regardless of visual selection. Use ALLSELECTED when user selections should define the ranking universe.
The table passed to RANKX is probably still filtered to the current row. Remove the item filter while keeping the category filter.
Start with a 30-minute data risk call Start with a 30-minute data risk call