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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! 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
Community Champion
Community Champion

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

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.