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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Peter_Yaacoub
Frequent Visitor

TOP N excluding specific values

 

Top 10 Growth % = 
VAR _rankingContext =
    VALUES ( Companies[Company] )
RETURN
    CALCULATE (
        [Net Sales Growth %],
        TOPN ( 10, ALL ( Companies[Company] ), [Net Sales Growth %] ),
        _rankingContext,
        NOT Companies[Company] IN { "Company A", "Company B" }
    )

 

Hello Power Bi Community,

 

I am seeking help with my Top N function. Currently, the function displays the top 8 rather than the top 10 companies since both company A and company B are in the top 10 for net sales growth. However, I want it to display top 10 after excluding those companies from the calculations. Any idea how to approach this?

 

Your help is much appreciated. 

 

Thanks,

Peter

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Peter_Yaacoub ,

Please try to update the formula of the measure [] as below and check if it can return your expected result... You can find the details in the attachment.

Top 10 Growth % = 
VAR _selcompany =
    SELECTEDVALUE ( 'Companies'[Company] )
VAR _rank =
    RANKX (
        FILTER (
            ALLSELECTED ( 'Companies'[Company] ),
            NOT Companies[Company] IN { "Company A", "Company B" }
        ),
        [Net Sales Growth %]
    )
RETURN
    IF (
        NOT _selcompany
            IN { "Company A", "Company B" }
            && _rank <= 10,
        [Net Sales Growth %],
        BLANK ()
    )

yingyinr_0-1678851884142.png

If the above one can't help you, please provide some raw data in your table (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

View solution in original post

2 REPLIES 2
MichaelaMul
Helper III
Helper III

Good morning! Would this measure help with filtering a table by the TopN brands, excluding names of specific brands? Previously, I was using a filter on the VIsual that showed the Top 3 Brands by Vol Sales, however I realized one of our own brands isn't the Top Brand in the category at a specific account and I want our brands to always be visible in the matrix

Anonymous
Not applicable

Hi @Peter_Yaacoub ,

Please try to update the formula of the measure [] as below and check if it can return your expected result... You can find the details in the attachment.

Top 10 Growth % = 
VAR _selcompany =
    SELECTEDVALUE ( 'Companies'[Company] )
VAR _rank =
    RANKX (
        FILTER (
            ALLSELECTED ( 'Companies'[Company] ),
            NOT Companies[Company] IN { "Company A", "Company B" }
        ),
        [Net Sales Growth %]
    )
RETURN
    IF (
        NOT _selcompany
            IN { "Company A", "Company B" }
            && _rank <= 10,
        [Net Sales Growth %],
        BLANK ()
    )

yingyinr_0-1678851884142.png

If the above one can't help you, please provide some raw data in your table (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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.