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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
gauravnarchal
Post Prodigy
Post Prodigy

How to create Power BI TOP N and others Report

Hello All.

 

I need to get the top 2 client group sales and the rest is to be shown as others. TopN client (number [No.]) will be selected from the filters (Advance filter) and rest all clients should show as other.

 

What best measure should I use to this result?

 

gauravnarchal_0-1595356699326.png

 

7-21-2020 7-48-34 PM.jpg

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @gauravnarchal ,

1. Create a new table manually like this:

top.png

2. Create these measures:

Total Sales =
CALCULATE (
    SUM ( 'Table'[Sale Amt] ),
    ALLEXCEPT ( 'Table', 'Table'[Client Group] )
)
Sales Amount Top =
CALCULATE (
    [Total Sales],
    KEEPFILTERS ( TOPN ( 2, ALL ( 'Table'[Client Group] ), [Total Sales] ) )
)
Sales Amount Other =
CALCULATE (
    [Total Sales],
    KEEPFILTERS (
        EXCEPT (
            ALL ( 'Table'[Client Group] ),
            TOPN ( 2, ALL ( 'Table'[Client Group] ), [Total Sales] )
        )
    )
)
Sales Amount Other Total Only =
IF ( NOT ( ISFILTERED ( 'Table'[Client Group] ) ), [Sales Amount Other] )
Sales Amount Top & Others =
IF (
    HASONEVALUE ( 'Top & Other'[Top] ),
    SWITCH (
        VALUES ( 'Top & Other'[Top] ),
        "Top2", [Sales Amount Top],
        "Other", [Sales Amount Other Total Only]
    ),
    [Sales Amount Top]
)

3. Use a Matrix visual to show the result:

top re.png

 

Attached my sample file that hopes to help you: How to create Power BI TOP N and others Report.pbix

 

Best Regards,
Yingjie Li

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

8 REPLIES 8
Anonymous
Not applicable

ok hear you go got the link to work PBIX

 

 

i hope this is a good solution for you 

v-yingjl
Community Support
Community Support

Hi @gauravnarchal ,

1. Create a new table manually like this:

top.png

2. Create these measures:

Total Sales =
CALCULATE (
    SUM ( 'Table'[Sale Amt] ),
    ALLEXCEPT ( 'Table', 'Table'[Client Group] )
)
Sales Amount Top =
CALCULATE (
    [Total Sales],
    KEEPFILTERS ( TOPN ( 2, ALL ( 'Table'[Client Group] ), [Total Sales] ) )
)
Sales Amount Other =
CALCULATE (
    [Total Sales],
    KEEPFILTERS (
        EXCEPT (
            ALL ( 'Table'[Client Group] ),
            TOPN ( 2, ALL ( 'Table'[Client Group] ), [Total Sales] )
        )
    )
)
Sales Amount Other Total Only =
IF ( NOT ( ISFILTERED ( 'Table'[Client Group] ) ), [Sales Amount Other] )
Sales Amount Top & Others =
IF (
    HASONEVALUE ( 'Top & Other'[Top] ),
    SWITCH (
        VALUES ( 'Top & Other'[Top] ),
        "Top2", [Sales Amount Top],
        "Other", [Sales Amount Other Total Only]
    ),
    [Sales Amount Top]
)

3. Use a Matrix visual to show the result:

top re.png

 

Attached my sample file that hopes to help you: How to create Power BI TOP N and others Report.pbix

 

Best Regards,
Yingjie Li

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

 

Anonymous
Not applicable

I would create a calculated table based on your distinct client groups. 

then add the following columns ot the table :
-Sales = Sum(sales amnt)

-rank = RANKX(All(client groups), [Sales],,,Dense)
-topn = if([rank] <= 2 , "Top 2", "Other" )

 

Does this make sense? 

@Anonymous  It is not summarizing others in one row. See below screenshot.

gauravnarchal_0-1595394358414.png

Anonymous
Not applicable

can you e-mail me a copy of the PBIX file and i can see what i can do to fix it 🙂

@Anonymous Here is the PBIX file

 

Anonymous
Not applicable

Dnerada_0-1595396681153.png

this is the end result of the matrix 

send me your e-mail and i can send your way sorry one drive is giving me issues tonight not enough coffee for it 🙂

Anonymous
Not applicable

can you send me your e-mail it wont attach the link for some reason 

 

it is all fixed and is a good solution 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.