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
natksi
New Member

Rankx for a specific category within a group

Hi, I am trying to get the following rank, but somehow my dax doesn't work.

 

CompanyCategorySalesRank
AA10001
AB5003
BA9992
BB4504

 

it should rank category among category A &B. 

 

I have tried:

rankx(all([company], [category]),

sum([sales]))

 

and variations with calculated columns.

 

Please help, thanks

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@natksi , A new measure

 

rankx(all(Table[company], Table[category]),calculate( sum([sales])),,desc, dense)

 

or

 a new column

Rankx(Table, [Sales],,desc, dense)

View solution in original post

3 REPLIES 3
natksi
New Member

hi @amitchandak, thanks for your previous reply!

How do you deal with rankx if [category] field is filtered in the visual? Would not need to rank all categories as in
rankx(all(Table[company], Table[category]),calculate( sum([sales])),,desc, dense), just the ones filtered for in the visual

natksi
New Member

Somehow the solution suggested doesn't work.

 

I think it is because [ Category] is filtered in my visual. So here, we want to rank companies in only 2 categories from the table. How do we achieve that in DAX? 

amitchandak
Super User
Super User

@natksi , A new measure

 

rankx(all(Table[company], Table[category]),calculate( sum([sales])),,desc, dense)

 

or

 a new column

Rankx(Table, [Sales],,desc, dense)

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.