Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
gyong
New Member

Rank function: How to Display Only Specific Ranks row

Hello everyone,

I want to create a function that assigns ranks to the quantity of categories purchased by customers and displays only the highest quantity (1st rank) among them.

I have calculated the rank of the quantity of categories purchased by customers using the following function.

 

=IF(HASONEVALUE('tab1'[category code]),
RANKX(ALL('tab1'[category name]), 'tab1'[sum of quantity]),
BLANK()
)

 

Is there a way to display only the 1st rank? The ultimate goal is to use this measurement to display the customer's order quantity and which categories they mainly purchase in a pivot table.

 

thank you all.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@gyong , use index function

 


calculate( Sum(Table['tab1'[sum of quantity]), keepfilters( INDEX(1, ALLSELECTED('tab1'[category name],'tab1'[Customer name]), ORDERBY(Sum(Table['tab1'[sum of quantity]),desc),, partitionBy ('tab1'[Customer name]))))


 

refer

Top/Bottom Performer by name and value- https://youtu.be/HPhzzCwe10U

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@gyong , use index function

 


calculate( Sum(Table['tab1'[sum of quantity]), keepfilters( INDEX(1, ALLSELECTED('tab1'[category name],'tab1'[Customer name]), ORDERBY(Sum(Table['tab1'[sum of quantity]),desc),, partitionBy ('tab1'[Customer name]))))


 

refer

Top/Bottom Performer by name and value- https://youtu.be/HPhzzCwe10U

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
rajendraongole1
Super User
Super User

Hi @gyong - To calculate the ranks the quantities of categories purchased by customers and then displays only the highest quantity (1st rank) in a pivot table

 

create below measure for the rank of the categories, you can replace the table and columns names as per your model.

 

CategoryRank = IF(
HASONEVALUE('tab1'[category code]),
RANKX(
ALL('tab1'[category name]),
[SumOfQuantity],
,
DESC,
DENSE
),
BLANK()
)

 

create another measure to find the highest category rank

TopCategoryQuantity = IF(
[CategoryRank] = 1,
[SumOfQuantity],
BLANK()
)

 

the above approach helps to displaying the customer's order quantity and the main categories they purchase in a pivot table with hightest category wise.

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors