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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Top N + Others on visualization (having difficulties with RANKX)

Hi Experts,

I've been trying for a while now to implement a TOP N + Others (As in, show the share of sales for the top N brands but include a representation for the rest of the brands). I tried following this guide: Filtering the top products alongside the other products in Power BI  but haven't been successful.

This is my main table and there are no relevant relations here:

MONTHMARKETCHANNELCLUSTER PLAYERMANUFACTURERBRANDFLAVORFLAVOR SEGMENTCATEGORYCALORIC CONTPACKAGINGSHARE TYPESHARE VALUE
01/set/22FQ 1CHAN 1TayvLigMullockCOLACOLASCSDREGPET 3/3,3LSOS99014
01/ago/22FQ 1CHAN 1TayvLigMullockCOLACOLASCSDD/LREFPETSOS81036
01/set/22FQ 2CHAN 1+2TayvLigMullockCOLACOLASCSDD/LPET 250SOS43058
01/set/22FQ 3CHAN 1+2TayvLigIpsUVASABORESCSDREGPET 400-599SOS83666
01/ago/22CTRYCHAN 1TayvLigIpsGUASABORESCSDREGLS/SLSSOS85450
01/set/22FQ 3CHAN 1+2IlpCycrustEtsGUASABORESCSDREGPET 250SOS25516
01/set/22FQ 3CHAN 1+2TayvLigDoibCOLACOLASCSDD/LKSSOS47614
01/ago/22FQ 4CHAN 1+2TayvLigLagonGRAPE FUSIONSABORESCSDD/LLT 350-399SOS18808
01/set/22FQ 2CHAN 1+2TayvLigLagonGUASABORESCSDREGLT 350-399SOS93411

 The dashboard itself is always filtered by Category and Share Type and I want this Top N to be responsive to filtering on other visuals (ie: by manufacturer, by cluster player, etc)

The ranking measure I created following the guide isn't responsive and to be honest I don't think it's doing what I mean for ti to be doing.

 

Ranking Top X = 
IF (
    ISINSCOPE ( 'QuickFlash'[BRAND] ),
    VAR TotalValue =
        -- This is the same as the [MONTH Value] measure which I made explicit here.
        CALCULATE (
            SUM(QuickFlash[SHARE VALUE]),
            AND(
                MONTH(QuickFlash[MONTH]) = MONTH(MAX(DataMax[MONTH])),
                YEAR(QuickFlash[MONTH]) = YEAR(MAX(DataMax[MONTH]))
            )
        )
    RETURN
        IF (
            TotalValue > 0,
            VAR VisibleBrands =
                CALCULATETABLE (
                    VALUES ( 'QuickFlash' ),
                    ALLSELECTED ( 'QuickFlash'[BRAND] )
                )
            VAR Ranking =
                RANKX (
                    VisibleBrands,
                    [MONTH Value],
                    Total Value
                )
            RETURN
               Ranking
        )
)

 

I didn't limit the number of ranking brands in this measure because I'm still trying to figure out what I'm doing wrong.

Anyway, at the moment, if I look at the brands and the ranking measure in a matrix I get:

- Some brands with repeat ranking values, even though they don't tie for value (Brand A, B and C are ranked as first, but Brand A has a Month Value of 172k while B has 188k and C has 45k;

- Some numbers that just don't make sense, as if it's not really aggregating by brand (ie: Brand D is ranked 1045 even though there are less than 200 brands total (less than 100 with the filters being used)

Sample data can be found here in excel format: Sample Data

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , refer if this approch can help

Power BI- TOPN with Others- https://youtu.be/I_TY4hVlzAE

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

2 REPLIES 2
Anonymous
Not applicable

Thanks, that worked like a charm.

amitchandak
Super User
Super User

@Anonymous , refer if this approch can help

Power BI- TOPN with Others- https://youtu.be/I_TY4hVlzAE

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

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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