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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

Dividing a measure by the value of the measure where Rank =1

Hi,

 

I have two measures, a "Rank" and the "Measure".  I need to divide all "Measure" by the "Measure" value where Rank =1.

 

This looks so easy but I can't get it to work!  any ideas greatly appreciated.  The "Desired" column is what I am trying to create.

 

 

RankMeasureDesired
1120001
2100000.833333
380000.666667
450000.416667



2 ACCEPTED SOLUTIONS
d_gosbell
Super User
Super User

To do a ranking you must be doing it over some column which is not visible in your sample data. So in the example below I've used a placeholder column called [Item] you will need to replace the reference to 'Table'[Item] with the reference to the actual column you are ranking over. 

 

Once you do this a pattern like the following should work:

 

Desired = 
var _rank1Measure = CALCULATE([Measure], FILTER(ALL('Table'[Item]),[Rank] = 1))
return DIVIDE([Measure], _rank1Measure)

 

View solution in original post

v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Create measures

Measure = SUM('Table'[value])

rank = RANKX(ALLSELECTED('Table'),[Measure],,DESC,Dense)

rank1 = CALCULATE([Measure],FILTER(ALLSELECTED('Table'),'Table'[rank]=1))

%1 = [Measure]/[rank1]

Capture11.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Create measures

Measure = SUM('Table'[value])

rank = RANKX(ALLSELECTED('Table'),[Measure],,DESC,Dense)

rank1 = CALCULATE([Measure],FILTER(ALLSELECTED('Table'),'Table'[rank]=1))

%1 = [Measure]/[rank1]

Capture11.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
d_gosbell
Super User
Super User

To do a ranking you must be doing it over some column which is not visible in your sample data. So in the example below I've used a placeholder column called [Item] you will need to replace the reference to 'Table'[Item] with the reference to the actual column you are ranking over. 

 

Once you do this a pattern like the following should work:

 

Desired = 
var _rank1Measure = CALCULATE([Measure], FILTER(ALL('Table'[Item]),[Rank] = 1))
return DIVIDE([Measure], _rank1Measure)

 

Anonymous
Not applicable

Superb, thanks this works.  This had really foxed me.

 

@mwegener - thanks I created the measures as you suggested but the slight issue was that within my data are multiple rows for the same entity and the top rank amount was not at the highest level

 

@d_gosbell - but when I added your additional measure it worked, thanks so much for your time, greatly appreciated

 

mwegener
Most Valuable Professional
Most Valuable Professional

Hi @Anonymous ,

 

try this

 

 

Measure =
VAR Rank1 =
    CALCULATE (
        SUM ( 'Table'[Measure] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Rank] = 1 )
    )
RETURN
    DIVIDE ( SUM ( 'Table'[Measure] ), Rank1 )

 

 

If I answered your question, please mark my post as solution, this will also help others.

Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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