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

Ranking based on value sorted in descending and percentage of Max Rank

Hi Power BI Community,

We have a requirement where we have the data coming from Excel as below : 

 

DeepakJha23_1-1657105346868.png

 

We are trying in Power BI to get the sales data sorted in the descending order and then rank them as Highest sales as 1 and so on. And the using this rank to do a percentage of Max rank as below in the last column :

 

DeepakJha23_3-1657105638638.png

 

I would appreciate any help on this.

 

@Greg_Deckler @amitchandak @tamerj1 @SpartaBI 

 

 

Thanks,

Deepak

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @DeepakJha23 
Please refer to the sample file with the solution https://we.tl/t-40Y6zDV7U8

1.png

Sales Amount = SUM ( Sales[Sales] )
Rank = RANKX ( ALLSELECTED ( Sales[Product] ), [Sales Amount] )
% of Max Rank = 
VAR TotalSales = CALCULATE ( [Sales Amount], ALLSELECTED ( Sales[Product] ) )
VAR CurrentRank = [Rank]
VAR T1 = ADDCOLUMNS ( ALLSELECTED ( Sales[Product] ), "@Amount", [Sales Amount] )
VAR T2 = TOPN ( CurrentRank, T1, [@Amount] )
VAR CommulativeSales = SUMX ( T2, [@Amount] )
RETURN
    DIVIDE ( CommulativeSales, TotalSales )

View solution in original post

3 REPLIES 3
tamerj1
Super User
Super User

Hi @DeepakJha23 
Please refer to the sample file with the solution https://we.tl/t-40Y6zDV7U8

1.png

Sales Amount = SUM ( Sales[Sales] )
Rank = RANKX ( ALLSELECTED ( Sales[Product] ), [Sales Amount] )
% of Max Rank = 
VAR TotalSales = CALCULATE ( [Sales Amount], ALLSELECTED ( Sales[Product] ) )
VAR CurrentRank = [Rank]
VAR T1 = ADDCOLUMNS ( ALLSELECTED ( Sales[Product] ), "@Amount", [Sales Amount] )
VAR T2 = TOPN ( CurrentRank, T1, [@Amount] )
VAR CommulativeSales = SUMX ( T2, [@Amount] )
RETURN
    DIVIDE ( CommulativeSales, TotalSales )

Thanks @tamerj1 .The solution worked. Kudos!

amitchandak
Super User
Super User

@DeepakJha23 , Try like

 

divide([Rank], maxx(Values(Table[Product]), [Rank]))

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.