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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Ajinkya369
Resolver III
Resolver III

Top 5 and Bottom 5 Products within each categories

Hi folks,

Data structure: 

Category A: Product1,Product2,Product3.....so on

Category B: Product1,Product2,Product3.....so on

I want to calculate Top 5 and Bottom 5 products within each category.For Top 5 Products within each category I have used this formula:

Top 5 Products within each category =
VAR RankingContext = VALUES(‘Dim Products’[Products])
return
CALCULATE([Sum of sales],TOPN(5,ALL(‘Dim Products’[Products]),[Sum of sales]),RankingContext)

I am using Category and Product(Drill down) in rows section of Matrix and the Measure " Top 5 Products within each category" in the values section.
Its working well for Top 5 but I need help in calculating the bottom 5 products within each category.

Thanks in advance.

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @Ajinkya369,
Can please share some dummy data with a similar data structure and expected results? It should help us clarify your scenario and test to coding formula.
How to Get Your Question Answered Quickly 
Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Ajinkya369
Resolver III
Resolver III

Hey @amitchandak ,

 

Thanks for the reply! It is for Top N products within each category whereas I am looking for Bottom N Products within each category.

 

Thanks,

Ajinkya

amitchandak
Super User
Super User

@Ajinkya369 , refer if this can help

https://www.sqlbi.com/articles/filtering-the-top-3-products-for-each-category-in-power-bi/

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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