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
cerebro
Helper I
Helper I

Show top 5 values, sum top 5 vales, sum others, sum totals

Hi everybody,

 

i would like to create the following table in Power BI:qPQb2
the problem is that it's either the top 5 and their sum or top5 agreggated, others and the totals. Is there any possibility to make any structure with subtotals work? I have some sample data but i am not sure how to upload it here.

Thanks in advance

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @cerebro ,

 

You can create a seperate table by entering data as follows.

3.png

Then create a calculated table

Table 2 = UNION(SELECTCOLUMNS(FILTER('Table',[topn]<=5),"Category",[Customer]),'Table (2)')

2.png

Create the measure

Values = 
IF (
    MAX ( 'Table 2'[Category] ) = "sum of top5",
    CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( 'Table', [topn] <= 5 ) ),
    IF (
        MAX ( 'Table 2'[Category] ) = "others",
        CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( 'Table', [topn] > 5 ) ),
        IF (
            MAX ( 'Table 2'[Category] ) = "total",
            CALCULATE ( SUM ( 'Table'[Value] ), ALL ( 'Table' ) ),
            CALCULATE (
                SUM ( 'Table'[Value] ),
                FILTER ( 'Table', [Customer] = MAX ( 'Table 2'[Category] ) )
            )
        )
    )
)

4.png

 

 

 

Best Regards,

Stephen Tao

 

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

4 REPLIES 4
Anonymous
Not applicable

Hi @cerebro ,

 

You can create a seperate table by entering data as follows.

3.png

Then create a calculated table

Table 2 = UNION(SELECTCOLUMNS(FILTER('Table',[topn]<=5),"Category",[Customer]),'Table (2)')

2.png

Create the measure

Values = 
IF (
    MAX ( 'Table 2'[Category] ) = "sum of top5",
    CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( 'Table', [topn] <= 5 ) ),
    IF (
        MAX ( 'Table 2'[Category] ) = "others",
        CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( 'Table', [topn] > 5 ) ),
        IF (
            MAX ( 'Table 2'[Category] ) = "total",
            CALCULATE ( SUM ( 'Table'[Value] ), ALL ( 'Table' ) ),
            CALCULATE (
                SUM ( 'Table'[Value] ),
                FILTER ( 'Table', [Customer] = MAX ( 'Table 2'[Category] ) )
            )
        )
    )
)

4.png

 

 

 

Best Regards,

Stephen Tao

 

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

thank you very much for this solution!

amitchandak
Super User
Super User

@cerebro , Try like

 

https://www.youtube.com/watch?v=UAnylK9bm1I

 

TOPN with other

 

https://www.proserveit.com/blog/ms-power-bi-topn-and-other

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

i got everything except for the the sum of top 5

because i cant add it as a line to the column with customer names.

I created a column that indicates the names of top 5 customers and every other customer receives the "other" lable. But i dont know how to create a top 5 sum in the same table 

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.