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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Filippomonti
Frequent Visitor

How to group rows with first N and other

Hello,

i'm facing a problem with a report of quantities sales.

I have 2 levels of row like this

- Nation 1

     - Customer 1

     - Customer 2

     - Customer N

- Nation N

And i need to group only the customer displaying all the nations. So the only level that have to change is customer to show the report (matrix) like this:

- Nation 1

   - Customer 1

   - Customer 2

   - Customer 3

   - Customer 4

   - Customer 5

   - Other

- Nation 2

   - Customer 1

   - Customer 2

   - Customer 3

   - Customer 4

   - Customer 5

   - Other

- Nation N

   - Customer 1

   - Customer 2

   - Customer 3

   - Customer 4

   - Customer 5

   - Other

I want to display automatically only the top 5 customer per sales and the others in a generic "Other" section. If i use the group function I have to do that manually but that's painfully long with lots of customers for different nations.

How can I solve this problem?

 

Thanks in advance

 

1 ACCEPTED SOLUTION
Samarth_18
Community Champion
Community Champion

Hi @Filippomonti ,

 

Since there is no sample data provided in the question so I can't write the code directly.However,you can refer below article for getting TopN based on the nation. It helped me and I hope it will help you as well.

 

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

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

4 REPLIES 4
Samarth_18
Community Champion
Community Champion

Hi @Filippomonti ,

 

Since there is no sample data provided in the question so I can't write the code directly.However,you can refer below article for getting TopN based on the nation. It helped me and I hope it will help you as well.

 

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

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Hi @Samarth_18 ,

Thank you very much for the support, I watched the video and it solved my problem.

Now, is there a way to alway display the "Others" row? I need to filter the matrix so i don't see rows with Sales Amount (as the video) = 0 but i need to see always Other.

 

Thank you in advance, best regards

 

Filippo

Is it possible for you to share your PBIX after removing confidential data?

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

I figured out how to do that and unfortunately I can't share my pbix. Anyway, thank you for your kind help!

Have a nice day 🙂

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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