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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Imagauthamam
Helper III
Helper III

Need Help in RANK DAX function (Dynamic Ranking)

I have the following in which I have to do dynamic Ranking.
First, it should see the region and then based on Total sales
When the region changes, it should start again from 1, (Similar to partition by in SQL).

 

Imagauthamam_0-1728296760719.png


I'm also attaching the dax function which I tried:

Dynamic_Rank = RANK(DENSE,ALLSELECTED('Dynamic Rank'[Total Sales]),ORDERBY('Dynamic Rank'[Region],ASC,'Dynamic Rank'[Total Sales],DESC))
 
The correct output should be:

UserIDRegionTotal SalesDynamic_Rank
1North20002
2North30001
3North30001
4South40001
5South40001
6South35002

Please let me know what am I missing in the RANK function
1 ACCEPTED SOLUTION
Kedar_Pande
Super User
Super User

@Imagauthamam 

DAX formula:

Dynamic_Rank = 
RANKX(
FILTER(
'YourTableName',
'YourTableName'[Region] = EARLIER('YourTableName'[Region])
),
'YourTableName'[Total Sales],
,
DESC,
Dense
)


If this helped, a Kudos 👍 or Solution mark would be great!
Cheers,
Kedar Pande
www.linkedin.com/in/kedar-pande

View solution in original post

4 REPLIES 4
Prashant_123
Helper I
Helper I

Hi Everyone

 

I want to Rank on basis of amount and also of new month starts then it should rank on basis of amount.

 

Month Amount Rank

Jan        234          1

Jan        200          2

Jan        100          3

Feb         400         1

Feb         149         2
 like this I want , as I have tried everything but it is not coming please help.

 

Imagauthamam
Helper III
Helper III

Hi @Kedar_Pande ,

Thanks for the Response. This works.
But is this not achievable through RANK function instead of RANKX function.


We have to use RANKX as we have to iterate in the table.

If this helped please Solution mark the original answer

Kedar_Pande
Super User
Super User

@Imagauthamam 

DAX formula:

Dynamic_Rank = 
RANKX(
FILTER(
'YourTableName',
'YourTableName'[Region] = EARLIER('YourTableName'[Region])
),
'YourTableName'[Total Sales],
,
DESC,
Dense
)


If this helped, a Kudos 👍 or Solution mark would be great!
Cheers,
Kedar Pande
www.linkedin.com/in/kedar-pande

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.