Ranking metrics
Many reports and analyses are built around the ranking of dimensions relative to measures, such as the top 10 salespeople based on YTD sales. Ranking measures can also help deliver cleaner and more intuitive report visualizations as they substitute small integer values for large numbers and decimal places. Ranking measures can be as simple as specifying a column and a measure, or more complex with unique ranking logic applied in distinct filter contexts.
Ranking measures in DAX are implemented via the RANKX()
function, which is an iterator like SUMX()
and FILTER()
. As an iterating function, two required input parameters include a table and the expression to be evaluated for each row of the table. The following two measures rank products based on the Internet Net Sales
measure:
Internet Net Sales Product Rank = RANKX(ALL('Product'[ProductAlternateKey]),[Internet Net Sales],,DESC,Skip)
Internet Net Sales Product Rank (All Products) =
VAR __ProdRankTable...