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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
community_pinki
Helper II
Helper II

TopN+Others using Pie chart

Hi All,

I have a Pie chart where each sub-category contributing to the total sales.
Now, I have a requirement that the pie chart should show only top 5 sub-category and remaining should be in Others part.
How can we do that using DAX?

 

Capture.PNG
Any Help would be Appriciated...

Thanks.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @community_pinki 

I think you can build a calculated column by DAX to show new subcategorys with Top5 and Others.

My Sample:

1.png

Top5 Flag is a calculated column.

Top5Flag =
VAR _Rank =
    RANKX (
        'Table',
        CALCULATE (
            SUM ( 'Table'[Value] ),
            FILTER ( 'Table', 'Table'[SubCategory] = EARLIER ( 'Table'[SubCategory] ) )
        ),
        ,
        DESC,
        DENSE
    )
RETURN
    IF ( _Rank <= 5, 'Table'[SubCategory], "Others" )

Result:

2.png

Best Regards,
Rico Zhou

 

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

5 REPLIES 5
Prr2023
Regular Visitor

 I am getting an error, saying SUM function cannot work with STRING. Please guide me. I am looking for the same soluction.

 

What is the type of data you are using? Do you want to make a sum of a field? A count?


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português





Prr2023
Regular Visitor

Hello all, 

 

Would you please explain, how you created Calculated column? My query is not working. 

 

Anonymous
Not applicable

Hi @community_pinki 

I think you can build a calculated column by DAX to show new subcategorys with Top5 and Others.

My Sample:

1.png

Top5 Flag is a calculated column.

Top5Flag =
VAR _Rank =
    RANKX (
        'Table',
        CALCULATE (
            SUM ( 'Table'[Value] ),
            FILTER ( 'Table', 'Table'[SubCategory] = EARLIER ( 'Table'[SubCategory] ) )
        ),
        ,
        DESC,
        DENSE
    )
RETURN
    IF ( _Rank <= 5, 'Table'[SubCategory], "Others" )

Result:

2.png

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

MFelix
Super User
Super User

Hi @community_pinki 

 

Check this detailed explanation about how to create the dinamic others part then you can use in any chart.

 

https://blog.gbrueckl.at/2019/05/power-bi-dynamic-topn-others-with-drill-down/

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português





Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.