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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
kaylastarr
Advocate V
Advocate V

Help using RankX as a measure

Hello All,

 

I am struggling to create a measure to display the rank in a table. I have a table with the following columns

Promo Name, Start Date, Region, Total Quoted Sales. I am trying to display the rank by Promo Name and Start date based on the sum of total sales.

 

My current measure is:

RankM = RANKX(ALLselected('Promo Summary Table'),CALCULATE(sum('Promo Summary Table'[Total Quoted Sales]), ALLEXCEPT('Promo Summary Table','Promo Summary Table'[Promo Name)),,DESC,Dense)

This is close to correct but instead of calculating for each PromoName - Start Date pair it calculates for each promo name 
kaylastarr_0-1718721421370.png

If I create a column key unique for each Promo Name and Start date then each rank is just one. Any help would be appreciated



1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @kaylastarr 

I create a table:

vyohuamsft_1-1718762253817.png

 

You can use the following DAX expression:

Rank Test =
ROWNUMBER (
    ALLSELECTED ( 'Table'[Promo Name], 'Table'[Start Date] ),
    ORDERBY ( 'Table'[Promo Name], DESC, 'Table'[Start Date], ASC )
)

 

Here is my preview:

vyohuamsft_0-1718762236640.png

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi, @kaylastarr 

I create a table:

vyohuamsft_1-1718762253817.png

 

You can use the following DAX expression:

Rank Test =
ROWNUMBER (
    ALLSELECTED ( 'Table'[Promo Name], 'Table'[Start Date] ),
    ORDERBY ( 'Table'[Promo Name], DESC, 'Table'[Start Date], ASC )
)

 

Here is my preview:

vyohuamsft_0-1718762236640.png

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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