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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Nobie
Helper II
Helper II

rankx in power bi

I need help in rankx function.
I want to calculae rankx on product based on sales values but i have 2 more columns added .
i have attached an excel screenshot . Plz help me.
i have attached a link for pbix file with dummy dataset. pbixFile 

Nobie_0-1685597785056.png

 



7 REPLIES 7
DOLEARY85
Super User
Super User

If you want it against every row you can use this:

 

RANKING = rankx(all('Table'[Product], 'Table'[Product]),calculate( sum([sales]),ALLEXCEPT('Table','Table'[Product])),,desc, dense)
 
DOLEARY85_1-1685606275270.png

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Hi @DOLEARY85 ,
thanks for the help.
but i didn't get the correct Rank , i have used your solution.
The second table which is highlighted, i want that type of rank.
when i used ur measure against all the columns prodcut,lines,check and sales. It not giving correct result.
can you please help me?

Hi,

 

i'm not sure what is different in your version but it seems to work as you pictured for me, i've uploaded the file below for you to look at:

 

https://drive.google.com/file/d/1lOGn9_WpJUhJJSTVNP6T4WWsl9h9MX3O/view?usp=sharing

 

DOLEARY85_1-1685609461233.png

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Hi, Thanks  for your response
I am attaching a Power bi pbix 
this contain a pbix file, where i have attached a dummy table data with pbix.

Hi, 

 

It looks as though it's working as intended unless you are wanting the rankx function to be dynamic when you select different products in the slicer. if that's the case change the ALL at the begining to ALLSELECTED.

 

if that's no the issue can you explain what the issue is,

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Hi,

I really want to thanks.

This is working in the dataset that I demo dataset.but in real dataset i am not getting the correct rank.

Can u ping me in my email address . alimdfarukh@gmail.com

So that we can connect for a min?

DOLEARY85
Super User
Super User

Hi, this would work for your summary table, just make sure the sales field is aggregated to sum:

 

rank =
RANKX (
    CALCULATETABLE (
        VALUES ( 'Table'[Product] ),
        ALLSELECTED ( 'Table'[Product] )
    ),
    CALCULATE ( SUM ( 'Table'[Sales]) )
)
 
DOLEARY85_0-1685606063361.png

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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