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
cbolling
Helper I
Helper I

Returning the Highest Rank Number from the Rank Measure

Hi There,

 

I have a list of customers that is fluid, and there is a RankX ranking them based on their revenue. Lets say that there are 1 through n customers, I want to take n and multiply it by .2 and then only display customers with rank <= n*0.2. In other words I want to only display the top 20% of my customers based on revenue. What is the best way to do this?

1 ACCEPTED SOLUTION
2 REPLIES 2
wdx223_Daniel
Super User
Super User

 

wdx223_Daniel_2-1602575540236.png

 

MxRankN :=
VAR pct = 0.4
VAR MxRx =
    RANKX (
        ALL ( Sales[Customer] ),
        CALCULATE ( SUM ( Sales[Revenue] ) ),
        MAXX (
            TOPN ( 1, ALL ( Sales[Customer] ), CALCULATE ( SUM ( Sales[Revenue] ) ) ),
            CALCULATE ( SUM ( Sales[Revenue] ) )
        ),
        ASC
    )
VAR n =
    INT ( pct * MxRx )
RETURN
    SUMX (
        VALUES ( Sales[Customer] ),
        IF (
            RANKX ( ALL ( Sales[Customer] ), CALCULATE ( SUM ( Sales[Revenue] ) ),, DESC ) <= n,
            CALCULATE ( SUM ( Sales[Revenue] ) )
        )
    )

 

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.

Top Solution Authors