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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
hill
Helper I
Helper I

Exclude specific values from top n

Hi all,

I want to calculate the sales of top 5 companies as % of total, alll things worked well, but I found I have name "Others" as a company name. I want to exclude it from the top 5 companies, so the top 5 would only count those with meaningful names, such as Apple or Google. But I also want to keep the data of "Others" in the total number, so I can calculate the concentration ratio of companies. 

 

In this case, simply putting a filter to exclude "Others" is not working.

Here is my current calculation:

 

Top 5 Concentration = DIVIDE(CALCULATE([Sales],topn(5,GROUPBY(data,data[companyname]),[Sales])),CALCULATE([Sales],ALLSELECTED(data[companyname])))
 

Could anyone help? Thanks a lot!

2 ACCEPTED SOLUTIONS

@hill , Try to create a measure like this and rank/TOPN on that

 

new sales =calculate([Sales], filter(data, data[companyname] <> "Others"))

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

View solution in original post

mahoneypat
Microsoft Employee
Microsoft Employee

Please try this expression instead.

 

Top 5 Concentration =
DIVIDE (
    CALCULATE (
        [Sales],
        TOPN (
            5,
            FILTER (
                VALUES ( data[companyname] ),
                data[companyname] <> "Others"
            ),
            [Sales], DESC
        )
    ),
    CALCULATE (
        [Sales],
        ALLSELECTED ( data[companyname] )
    )
)

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

6 REPLIES 6
mahoneypat
Microsoft Employee
Microsoft Employee

Please try this expression instead.

 

Top 5 Concentration =
DIVIDE (
    CALCULATE (
        [Sales],
        TOPN (
            5,
            FILTER (
                VALUES ( data[companyname] ),
                data[companyname] <> "Others"
            ),
            [Sales], DESC
        )
    ),
    CALCULATE (
        [Sales],
        ALLSELECTED ( data[companyname] )
    )
)

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Thank you! that is really great

amitchandak
Super User
Super User

@hill , refer for TOPN with Others

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

 

Refer TOPN : https://www.youtube.com/watch?v=QIVEFp-QiOk

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

Thank you for your reply, but I am afraid that you are not answering my question.

 

"Others" is a company name, not a remaining part of top 5. Instead, it's part of top 5

"Others" is the aggregation of all small companies. So it can be very large to be top 1 in the category

@hill , Try to create a measure like this and rank/TOPN on that

 

new sales =calculate([Sales], filter(data, data[companyname] <> "Others"))

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

Thank you very much! it works for me 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 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.

Top Solution Authors
Top Kudoed Authors