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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount 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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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