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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ebalmeida
Frequent Visitor

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

@ebalmeida , refer if this approch can help

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

View solution in original post

2 REPLIES 2
ebalmeida
Frequent Visitor

Thanks, that worked like a charm.

amitchandak
Super User
Super User

@ebalmeida , refer if this approch can help

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.