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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
dataaanana
Frequent Visitor

How can I return only the third highest/lowest category as a measure?

[Edited please see sample file here]

 

Hello! I'm using this measure to get the item that received the most and least ordered:

 

Items Sold = COUNT(Orders[order_id])
 
MostSoldItem =
CALCULATE(
    VALUES(Menu[item_name]),
    FILTER(
        ALL(Menu[item_name]),
        [Items Sold] = MAXX(ALL(Menu[item_name]), [Items Sold])
    )
)
 
LeastSoldItem =
CALCULATE(
    VALUES(Menu[item_name]),
    FILTER(
        ALL(Menu[item_name]),
        [Items Sold] = MINX(ALL(Menu[item_name]), [Items Sold])
    )
)
 
These measures work, but now I want to find the third item that received the most orders, as well as the third item that received the least orders.
 
I created a Rank measure to help me achieve this:
 
ItemRanks = CALCULATE(RANKX(ALL(Menu[item_name]),[Items Sold],,DESC))
 
But I'm not sure how I can use this measure to help me return what I want. Please help! Thank you.
 
 
 
 
 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @dataaanana ,

 

We can create measures.

rank1 = RANKX(ALL(Menu),[Items Sold],,DESC) 
rank2 = RANKX(ALL(Menu),[Items Sold],,ASC) 
the third item(least) = CALCULATE(MAX('Menu'[item_name]),FILTER(ALL('Menu'),[rank2]=3))
the third item(most) = 
CALCULATE(MAX('Menu'[item_name]),FILTER(ALL('Menu'),[rank1]=3))

Then the result is as follows.

vtangjiemsft_0-1703491124446.png

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @dataaanana ,

 

We can create measures.

rank1 = RANKX(ALL(Menu),[Items Sold],,DESC) 
rank2 = RANKX(ALL(Menu),[Items Sold],,ASC) 
the third item(least) = CALCULATE(MAX('Menu'[item_name]),FILTER(ALL('Menu'),[rank2]=3))
the third item(most) = 
CALCULATE(MAX('Menu'[item_name]),FILTER(ALL('Menu'),[rank1]=3))

Then the result is as follows.

vtangjiemsft_0-1703491124446.png

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

FreemanZ
Super User
Super User

hi @dataaanana , 

 

try to post some sample data

Hello! Here's the sample data: [Edited please see sample file here]

 

Thank you so much!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors