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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. 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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

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