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
Anonymous
Not applicable

Ranking Column by Sub Category (RANKX)

Hello Everyone,

 

I have a feeling that this question has already been answered. But I still have to ask again. I found a few posts here explaining similar situations. For some reason solutions did not work for me. Not sure if this is my fault or it actually is a different case.

 

Need to create a ranking colulmn in PowerPivot - manufacturer sales within a product category. Based on the ranking manufacturers will be assigned different names/group names. So, rank 1 in product category A may become "Awesome", but rank 1 in product category B may become "Just OK". I am attaching screen for your reference.

 

Also, the data set has transactions for two years (2017-18). The ranking needs to be done only by 2018 sales.

 

Any ideas? My feeling is RANKX needs to be utilized. Sample Data.JPG

1 ACCEPTED SOLUTION

Ok, do this:

 

Amount Measure:=sum([Amount])

Rank Measure:=RANKX(ALL(Table1[Manufacturer_ID]),[Amount Measure])

 

and heres it working regardless of year:

Capture.PNG

If this doesnt work you might need to post a picture of your data structure so we can have a look at tables that need to be taken account of. There is also some great info here: https://powerpivotpro.com/2015/06/rankx-apalooza-within-and-across-groups-with-filters-etc/  

 

 

 

 

// if this is a solution please mark as such

// if this is a solution please mark as such. Kudos always appreciated.

View solution in original post

3 REPLIES 3
samdthompson
Memorable Member
Memorable Member

Hello, try this:

 

=RANKX(FILTER(Table1,[Manufacturer_ID]=EARLIER([Manufacturer_ID])),CALCULATE(sum(Table1[Amount]),ALLEXCEPT(Table1,Table1[Product_ID],Table1[Manufacturer_ID])))

 

here it is working, note that the expected rank of AAA/790 should be 1 given that its the largest of the 3 manufacturers for sales of that product:

 

Capture.PNG 

 

 

 

// if this is a solution please mark as such

// if this is a solution please mark as such. Kudos always appreciated.
Anonymous
Not applicable

Thank you for quick reply. Unfortunately, the solution is different from what is needed. The data I show in my original post is not complete and cannot be used. I pasted this sub set only to demonstrate the data structure. Let me try to explain the end result again.

 

The data set contains sales by manufacturer and product category in years 2017 and 2018.

Manufacturers are ranked by YTD sales in 2018 within a product category.

The rank 1 should be assigned to every line in transactions table for a largest manufacturer of this particular product.

Exapmle: AAA is number one by sales volume in 2018 for product X --> every transaction for manufacturer AAA and product X should be marked as 1 in "Rank" column, regardless of the year.

 

I hope this clarifies the case. Thank you all in advance.

Ok, do this:

 

Amount Measure:=sum([Amount])

Rank Measure:=RANKX(ALL(Table1[Manufacturer_ID]),[Amount Measure])

 

and heres it working regardless of year:

Capture.PNG

If this doesnt work you might need to post a picture of your data structure so we can have a look at tables that need to be taken account of. There is also some great info here: https://powerpivotpro.com/2015/06/rankx-apalooza-within-and-across-groups-with-filters-etc/  

 

 

 

 

// if this is a solution please mark as such

// if this is a solution please mark as such. Kudos always appreciated.

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.