Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
maurcoll
Helper III
Helper III

Rank with custom sort

Good Morning, I need some help please with the RankX function.

I have the following table the rank number is being created via a measure: 

Store Rank =
RANKX ( ALLSELECTED(Table[Store] ),
[Total Sales] )
 
which works and when i select 2 or 3 stores the ranking amends according which is what i want it to do.
What i need to do is change the sort order in the ranking from lowest to highest so the lowest sales would be Ranked as 1 and so on.
 
SalesRankStore
21143.4881E
3841.6092F
3459.4393O
2949.7974K
2848.5985P
2679.7396M
2467.597D
2396.1758A
2380.2929H
2285.87410C
2247.68211G
2238.72912L
2235.9413B
2181.59114N
2031.12515J
1744.79616I
1 ACCEPTED SOLUTION
maurcoll
Helper III
Helper III

I worked it out as 

Store Rank =
RANKX ( ALLSELECTED(Table[Store] ),
[Total Sales] , , asc, dense)
and this seems to be working

View solution in original post

2 REPLIES 2
maurcoll
Helper III
Helper III

I worked it out as 

Store Rank =
RANKX ( ALLSELECTED(Table[Store] ),
[Total Sales] , , asc, dense)
and this seems to be working
barritown
Super User
Super User

Hi @maurcoll,

 

What if you put a minus before [Total Sales]?

 
Store Rank =
RANKX ( ALLSELECTED(Table[Store] ),
-[Total Sales] )

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors