0
0
Power BIbi_tool~10 mins

RANKX for ranking in Power BI - Cell-by-Cell Formula Trace

Choose your learning style9 modes available
Sample Data

Sales data for different fruits with their sales numbers.

CellValue
A1Product
B1Sales
A2Apples
B2150
A3Bananas
B3200
A4Cherries
B4120
A5Dates
B5200
A6Elderberries
B690
Formula Trace
RANKX(ALL('Table'[Product]), CALCULATE(SUM('Table'[Sales])), , DESC, Skip)
Step 1: ALL('Table'[Product])
Step 2: CALCULATE(SUM('Table'[Sales])) for each product
Step 3: RANKX over products by their sales values
Cell Reference Map
     A          B
1 Product    Sales
2 Apples     150  
3 Bananas    200  
4 Cherries   120  
5 Dates      200  
6 Elderberries 90 

Formula references all products in column A and sales in column B.
The formula uses all products from column A and their sales from column B to calculate ranks.
Result
     A          B       C
1 Product    Sales   Rank
2 Apples     150     3
3 Bananas    200     1
4 Cherries   120     4
5 Dates      200     1
6 Elderberries 90     5
The Rank column shows the rank of each product based on sales. Bananas and Dates share rank 1 because they have the highest sales.
Sheet Trace Quiz - 3 Questions
Test your understanding
What does the ALL('Table'[Product]) part do in the formula?
AIt filters only the top product.
BIt removes filters so all products are ranked together.
CIt sums the sales for each product.
DIt sorts the products alphabetically.
Key Result
RANKX ranks items by a measure over all items ignoring filters, ties get same rank.