DAX Measure to rank by category and subcategory

john-paul

New Member
Joined
Nov 23, 2008
Messages
28
Hi,

I have loaded a table (named "Data") into Powerpivot and would like a measure to rank by Product in each city using a ref number.
I also want this rank to stay even if I filter later.

CityProductRefRANK I want
SydneyBike1001
SydneyBike1022
SydneyBike1053
SydneyBike1124
SydneyBike1135
SydneyCar1011
SydneyCar1032
SydneyCar1043
MelbourneBike1061
MelbourneBike1082
MelbourneBike1113
MelbourneCar1071
MelbourneCar1092
MelbourneCar1103

<tbody>
</tbody>

Hope you can help.

Thanks,
John
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

gazpage

Active Member
Joined
Apr 17, 2015
Messages
393
Given you haven’t had a response...

You want something like:

=RANKX(
ALLEXCEPT( Product, Category ),
SUM( Reference )
)
 
Last edited:

john-paul

New Member
Joined
Nov 23, 2008
Messages
28
Thanks gazpage.

Based on your suggestion I have used:

RANKX(
ALLEXCEPT( Data, Data[Product], Data[City]) ,
CALCULATE(SUM( [Ref]) )
)

This seems to work great.
Do you know if I can reverse the rank order so that lowest ref number is ranked first etc?

Thanks again,
John
 

gazpage

Active Member
Joined
Apr 17, 2015
Messages
393
Just google RANKX DAX. You will need another parameter, I forget if is is a 0 or 1.
 

john-paul

New Member
Joined
Nov 23, 2008
Messages
28
I have it working with the below, but each rank commences with 2 - there is no 1st rank.

Anyone able to help? Thanks.

IF(
HASONEVALUE( Data[Product] ),
RANKX(
ALLEXCEPT( Data,Data[Product],Data[City]),
[Sum_REF] , ,
ASC,Dense)
)
 

Forum statistics

Threads
1,143,659
Messages
5,720,134
Members
422,267
Latest member
olund

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
Top