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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
akhaliq7
Post Prodigy
Post Prodigy

How to create “others” in a pie chart

I need a way to show for example top 3 categories for sales and the rest of the categories in a others value. E.g. sales[orders] and categories[category name] are the tables and fields being used.

1 ACCEPTED SOLUTION
PiEye
Resolver II
Resolver II

Hi Akhaliq!

 

The best way I've found to do this so far is to create a DAX table and measure that work this out for you on the fly. Not my own solution, but it's worked for me and has been very useful.

Gerhard Brueckl provides a great explanation in his blog: https://blog.gbrueckl.at/2019/05/power-bi-dynamic-topn-others-with-drill-down/

Basically you create the dax table with all the categories unioned with an "other" row, and within that use a measure that returns a value only for the topN categories, and the remaining total in the "other" row.

 

Let us know if this helps!

Pi

 

View solution in original post

4 REPLIES 4
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

I tried to create a sample pbix file like below.

Picture1.png

 

 

Orders TopN and Others =
VAR topnorders =
    CALCULATE (
        SUM ( Sales[Orders] ),
        KEEPFILTERS (
            TOPN (
                SELECTEDVALUE ( 'TopN'[TopN] ),
                ALL ( Categories ),
                CALCULATE ( SUM ( Sales[Orders] ) ), DESC
            )
        )
    )
VAR allorders =
    CALCULATE ( SUM ( Sales[Orders] ), REMOVEFILTERS () )
RETURN
    IF (
        SELECTEDVALUE ( Categories[Category] ) = "Others",
        allorders - topnorders,
        topnorders
    )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

I tested this solution but the others part always shows the sum of all the categories. When the others value should change so if there are 3 categories shown the others should show only show the sum of values for the remaining 16 categories.

Never too late - I looked into this issue and managed to correct the code for the measure used. 

Orders TopN and Others = 
VAR topnordersTable =
    TOPN (
        SELECTEDVALUE ( 'TopN'[TopN] ),
        ALL ( Categories ),
        CALCULATE ( SUM ( Sales[Orders] ) ), DESC
    )
VAR topnorders =
    CALCULATE (
        SUM ( Sales[Orders] ),
        KEEPFILTERS ( topnordersTable )
    )
VAR otherorders =
    CALCULATE (
        SUM ( Sales[Orders] ),
        REMOVEFILTERS ( Categories ),
        EXCEPT ( ALL ( Categories ), topnordersTable )
    )
VAR allorders =
    CALCULATE ( SUM ( Sales[Orders] ), REMOVEFILTERS () )
RETURN
    IF (
        SELECTEDVALUE ( Categories[Category] ) = "Others",
        otherorders,
        topnorders
    )

 What this does is it makes sure topnorders value is not set to 0 in the return statement, (which was an issue in the original code) as 'Other' is not a top N value, which cause for this variable to be set to 0 at the very end of the code.

PiEye
Resolver II
Resolver II

Hi Akhaliq!

 

The best way I've found to do this so far is to create a DAX table and measure that work this out for you on the fly. Not my own solution, but it's worked for me and has been very useful.

Gerhard Brueckl provides a great explanation in his blog: https://blog.gbrueckl.at/2019/05/power-bi-dynamic-topn-others-with-drill-down/

Basically you create the dax table with all the categories unioned with an "other" row, and within that use a measure that returns a value only for the topN categories, and the remaining total in the "other" row.

 

Let us know if this helps!

Pi

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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