0
0
Power BIbi_tool~5 mins

RANKX for ranking in Power BI - Step-by-Step Guide

Choose your learning style9 modes available
Introduction
RANKX helps you order your data by giving each item a rank number based on a value. This is useful when you want to see who is first, second, or third in sales, scores, or any numbers.
When you want to show the top 5 products by sales on a report page.
When you need to rank employees by their monthly performance scores.
When you want to compare regions by their total revenue and show their rank.
When you want to create a leaderboard for customers based on purchase amounts.
When you want to highlight the best-selling items in a category.
Steps
Step 1: Open
- Power BI Desktop
Your report and data model are visible
Step 2: Click
- Modeling tab
Modeling options appear
Step 3: Click
- New measure
A formula bar opens to write a DAX measure
Step 4: Type
- formula bar
The measure is created and ready to use
💡 Use syntax like: Rank = RANKX(ALL('Table'[Column]), SUM('Table'[Value]))
Step 5: Add
- a table or matrix visual
You see the data with the new rank numbers next to each item
Step 6: Sort
- the visual by the Rank measure
Items appear ordered from lowest to highest rank
Before vs After
Before
A table visual shows products with their sales amounts but no order or rank
After
The same table visual shows products with a new Rank column numbering products from 1 for highest sales down
Settings Reference
RANKX function
📍 DAX formula bar
Defines how the ranking is calculated and displayed
Default: Descending order, skip ranking
Common Mistakes
Using RANKX without ALL() in the first argument
This causes ranking to be limited by current filters, giving wrong ranks
Use ALL('Table'[Column]) to remove filters and rank all items properly
Ranking by a column instead of an aggregation like SUM or AVERAGE
Ranking by a column value can give incorrect or meaningless ranks
Rank by an aggregation expression like SUM('Table'[Value])
Summary
RANKX assigns rank numbers to items based on a value or measure.
Use ALL() inside RANKX to rank all items ignoring filters.
Rank by aggregated values like SUM for meaningful results.