Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi guys,
I'm having a little trouble around the use of the RANKX function. I've tried some videos/answers here but I feel like I'm missing something obvious, please be gentle!
I have two tables. Joined with a 1 - * relationship.
Call Occurance
Call_ID
Caller_ID
Call_DateTime
Caller
Caller_ID
Name
Country
(New column) Country Rank (see below)
I'm placing them in a table and attempting to rank the Country, by using the Total Calls #. My expectation is for the Caller table Country Rank to have a very neatly ordered 1,2,3,4, I don't need them to change with slicer selection. But instead I'm returning all 1's for Country Rank.
| Caller_ID | Name | Country | Country Rank |
| ABC1 | Joe | UK | 2 |
| ABC2 | Mitch | USA | 1 |
| ABC3 | John | USA | 1 |
| ABC4 | Kevin | USA | 1 |
| ABC5 | Darla | UK | 2 |
| ABC6 | Lucy | UK | 2 |
| ABC7 | Rebecca | USA | 1 |
| ABC8 | Astrid | Norway | 3 |
Does anyone have any wisdom to suggest what's going wrong? Thanks in advance.
(edits: clarity, spelling)
Solved! Go to Solution.
Hi @NotAHobbyBI
Make sure you are creating a measure not a column, then try
Country Rank =
RANKX (
ALLSELECTED ( Caller[Country] ),
CALCULATE ( DISTINCTCOUNT ( 'Call Occurance'[Call_ID] ) )
)
Hi,
Please check the below picture and the attached pbix file.
I tried to create a sample pbix file like below.
It is for creating a new column.
Country call count CC =
VAR _currentcountry = Caller[Country]
VAR _countcall =
ADDCOLUMNS (
Caller,
"@countcall", COUNTROWS ( RELATEDTABLE ( 'Call Occurance' ) )
)
VAR _groupbycountry =
GROUPBY (
_countcall,
Caller[Country],
"@countcallbycountry", SUMX ( CURRENTGROUP (), [@countcall] )
)
RETURN
SUMX (
FILTER ( _groupbycountry, Caller[Country] = _currentcountry ),
[@countcallbycountry]
)
Rank country CC =
RANKX ( Caller, Caller[Country call count CC],, DESC, DENSE )
Just looking at this solution (it's far more elaborte). Would this route be suitable for workings towards a 'Top N + Others' type solution?
Hi @NotAHobbyBI
Make sure you are creating a measure not a column, then try
Country Rank =
RANKX (
ALLSELECTED ( Caller[Country] ),
CALCULATE ( DISTINCTCOUNT ( 'Call Occurance'[Call_ID] ) )
)
Yep. Was the measure/column difference. I'll go look up why that is.
Thank you!
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 6 | |
| 6 | |
| 4 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 24 | |
| 17 | |
| 10 | |
| 7 | |
| 6 |