Fighting with RANKX function

Ppivot

New Member
Joined
Feb 3, 2017
Messages
4
Hello Guys!!

I´ve been fighting for all day long with the function RANKX and I can´t be able to find a solution:

The function is simple but it doesn´t work as I expected:

I want to do a ranking of Sales by ID, but (here it´s where i found the problem) the Pivot table have to accept other references (rows) without modify the Rankx function, such as Client name and Country,...


If I only select into the table the ID the result is correct:

Product 1Product 2
IDNetSalesRankNetSalesRank
6032299698.216 €301.476.888 €1
60081106426513.356 €2
60301834408.914 €177.795 €62
603043087.343 €226417.174 €3
603089783.569 €272393.316 €4

<tbody>
</tbody>



However when I introduce another Row field the Rankx stops working properly, and I only get the correct result if i look at the ID Total:


Product 1Product 2
IDClientCountryNetSalesRankNetSalesRank
60322996Client 1Spain98.216 €11.476.888 €1
60322996 Total98.216 €301.476.888 €1
60081106Client 2England1513.356 €1
60081106 Total426513.356 €2
60301834Client 3USA408.914 €177.795 €1
60301834 Total408.914 €177.795 €62
60304308Client 4China7.343 €1417.174 €1
60304308 Total7.343 €226417.174 €3
60308978Client 5Spain3.569 €1393.316 €1
60308978 Total3.569 €272393.316 €4

<tbody>
</tbody>

The function:

Rank := RANKX ( ALL(Table[ID]) , SUM(Table[Net_Sales]) )

So Would it be possible to get the value from the Id subtotal in the row?

Thanks!!!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
This is a guess - I really need to test it but I am on my phone. Try wrapping the current measure inside this.

=calculate( your current formula here, ALLexcept(table,table[id]))
 
Upvote 0
This is a guess - I really need to test it but I am on my phone. Try wrapping the current measure inside this.

=calculate( your current formula here, ALLexcept(table,table[id]))

Thank you Matt, it almost work but not completely. I mean, it works great with totals however when I introduce the Product Category in the Columns, the result is not correct.

I attached the file to make it easier.

https://www.dropbox.com/s/68dlglqf606wv6d/Rank.xlsx?dl=0

Thank you
 
Upvote 0
This is a guess - I really need to test it but I am on my phone. Try wrapping the current measure inside this.

=calculate( your current formula here, ALLexcept(table,table[id]))

This is a guess - I really need to test it but I am on my phone. Try wrapping the current measure inside this.

=calculate( your current formula here, ALLexcept(table,table[id]))


I think I have it, thank you a lot for your Tip!!!!

The formula: (If it can help to others)


Calculate(

RANKX( ALL(Table[ID] , SUM(Table[Net Sales] ) ,
ALLEXCEPT( Table, Table[ID], Calendar, Category )
)


In the ALLEXCEPT you have to put all the filters that you wanna still be affected in the Pivot Table, that's why I've put it the Calendar and Category Tables.
 
Upvote 0

Forum statistics

Threads
1,214,631
Messages
6,120,640
Members
448,974
Latest member
DumbFinanceBro

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top