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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register 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

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.