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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
a4
Helper III
Helper III

How to optimize the RANKX measure

Hi all

 

I have a  rank measure:

 

Rank  = CALCULATE( RANKX(ALL('salesorderdetails'[Trim name]),ROUND([Gross Premium(USD) minus Commission (USD)],2),,DESC,Dense),ALLSELECTED('salesorderdetails'),VALUES('salesorderdetails'[Trim name]))
When I remove this measure from table visual it brings down the excution time down to 2 seconds and performance is improved. So, clearly there is a problem with the Rank measure.
 
Please suggest a way to optimize the RANKX function.
 
Kind Regards
Amit Kumar
10 REPLIES 10
amitchandak
Super User
Super User

@a4 , Try like

Rank = RANKX(ALLSELECTED('salesorderdetails'[Trim name]),ROUND([Gross Premium(USD) minus Commission (USD)],2),,DESC,Dense)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi Amit,

This formula doesn't give the desired result. All the ranks are same.

 

Kind Regards

Amit Kumar

az38
Community Champion
Community Champion

Hi @a4 

first, try to debug it.

remove ALLSELECTED('salesorderdetails') and check performance

then remove VALUES('salesorderdetails'[Trim name]) and check performance

in order to find the biggest memory consumer.

then we can try to suggest smth.


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
harshnathani
Community Champion
Community Champion

Hi @a4 ,

 

Try this.

Rank =

RANKX(ALL('salesorderdetails'[Trim name]),ROUND([Gross Premium(USD) minus Commission (USD)],2),,DESC,Dense)

 

Also, if you can share sample data. 

 

Regards,

Harsh Nathani

 

 

 

HI @a4 ,

 

Share sample .pbix and screen shot of your table and vizualisation.

 

Also you can try this

RANKX(ALLSELECTED('salesorderdetails'[Trim name]),CALCULATE(ROUND([Gross Premium(USD) minus Commission (USD)],2)),,DESC,Dense)

 

Regards,

Harsh Nathani

Hi Harsh,
This formula also didn't work.Please find a acreenshot for better understanding

InkedCapture_LI.jpg

 

[Gross Premium(USD) minus Commission (USD)] (Which is used in rank measure) = Net Premium (USD)

 

 

Please suggest a better formula for optimization.

 

Kind Regards

Amit Kumar

harshnathani
Community Champion
Community Champion

Hi @a4 ,

 

What was the output of the above formula.

 

Not sure why this is not working. Maybe something to do with measures.

 

RANK = RANKX(ALL(Salesorderdetails),ROUND([Gross Premium(USD) minus Commission (USD)],2)),,DESC,Dense)

 

Regards,

Harsh Nathani

Hi Harsh,

The formula which I have used gives the correct result, the only problem is that it is not optimized.

Please refer my first post for the formula.

 

Kind Regards

Amit Kumar

Hi Harsh,

The formula which you mentioned doesn't give the desired result.All the Trim Name has rank with this formula.

Please suggest anything else.

 

 

Kind Regards

Amit Kumar

Hi Harsh,

The formula which you mentioned doesn't give the desired result.All the Trim Name has the same rank with this formula.

Please suggest anything else.

 

 

Kind Regards

Amit Kumar

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.