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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.