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] )
avatar user

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)