DAX Measure to rank by category and subcategory

john-paul

New Member
Joined
Nov 23, 2008
Messages
37
Office Version
  1. 365
Platform
  1. Windows
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.

Sydney
Sydney
Sydney
Sydney
Sydney
Sydney
Sydney
Sydney
Melbourne
Melbourne
Melbourne
Melbourne
Melbourne
Melbourne

<tbody>
[TD="class: xl63"]City[/TD]
[TD="class: xl65, width: 64"]Product[/TD]
[TD="class: xl65, width: 64"]Ref[/TD]
[TD="class: xl65, width: 64"]RANK I want[/TD]

[TD="class: xl64"]Bike[/TD]
[TD="class: xl64"]100[/TD]
[TD="class: xl64"]1[/TD]

[TD="class: xl64"]Bike[/TD]
[TD="class: xl64"]102[/TD]
[TD="class: xl64"]2[/TD]

[TD="class: xl64"]Bike[/TD]
[TD="class: xl64"]105[/TD]
[TD="class: xl64"]3[/TD]

[TD="class: xl64"]Bike[/TD]
[TD="class: xl64"]112[/TD]
[TD="class: xl64"]4[/TD]

[TD="class: xl64"]Bike[/TD]
[TD="class: xl64"]113[/TD]
[TD="class: xl64"]5[/TD]

[TD="class: xl64"]Car[/TD]
[TD="class: xl64"]101[/TD]
[TD="class: xl64"]1[/TD]

[TD="class: xl64"]Car[/TD]
[TD="class: xl64"]103[/TD]
[TD="class: xl64"]2[/TD]

[TD="class: xl64"]Car[/TD]
[TD="class: xl64"]104[/TD]
[TD="class: xl64"]3[/TD]

[TD="class: xl64"]Bike[/TD]
[TD="class: xl64"]106[/TD]
[TD="class: xl64"]1[/TD]

[TD="class: xl64"]Bike[/TD]
[TD="class: xl64"]108[/TD]
[TD="class: xl64"]2[/TD]

[TD="class: xl64"]Bike[/TD]
[TD="class: xl64"]111[/TD]
[TD="class: xl64"]3[/TD]

[TD="class: xl64"]Car[/TD]
[TD="class: xl64"]107[/TD]
[TD="class: xl64"]1[/TD]

[TD="class: xl64"]Car[/TD]
[TD="class: xl64"]109[/TD]
[TD="class: xl64"]2[/TD]

[TD="class: xl64"]Car[/TD]
[TD="class: xl64"]110[/TD]
[TD="class: xl64"]3[/TD]

</tbody>

Hope you can help.

Thanks,
John
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Given you haven’t had a response...

You want something like:

=RANKX(
ALLEXCEPT( Product, Category ),
SUM( Reference )
)
 
Last edited:
Upvote 0
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
 
Upvote 0
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)
)
 
Upvote 0

Forum statistics

Threads
1,223,902
Messages
6,175,278
Members
452,629
Latest member
SahilPolekar

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