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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

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
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.