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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Rank within a group based on output of a measure

Hi Team,

 

I need to have a ranking to my Products based on Category and Its YTD sales.

 

Here is the sample data.

DateProduct NameCategoryYTD Sales In CR
23-06-2021ABSL Nifty 50Equal Weight300
23-07-2021ABSL Nifty 50Rregular200
22-08-2021ABSL Nifty 50Equal Weight230
21-09-2021ABSL Nifty 50Equal Weight350
21-10-2021ABSL Nifty 50Growth190
23-06-2021ABSL Banking And FinanceFinance291
23-07-2021ABSL Banking And FinanceGrowth344
22-08-2021ABSL Banking And FinanceFinance53
21-09-2021ABSL Banking And FinanceEqual Weight430
21-10-2021ABSL Banking And FinanceEqual Weight540
20-11-2021ABSL Banking And FinanceRegular222
23-06-2021ICICI Prudential US BluechipInfra120
23-07-2021ICICI Prudential US BluechipFinance123
22-08-2021ICICI Prudential US BluechipRegular321
21-09-2021ICICI Prudential US BluechipGrowth324
21-10-2021ICICI Prudential US BluechipEqual Weight244

 

Expected Output: Pease note that the Total YTD is a meausre and hence we would need measure to calcuate RANK - NOT A COLUMN - this is a subset of data we have and all this is coming from different tables so a calcuated RANK column is not going to work!

Product NameCateoryTotal YTDRank
ABSL Banking And FinanceEqual Weight9701
ABSL Banking And FinanceGrowth3442
ABSL Banking And FinanceFinance3443
ABSL Banking And FinanceRegular2224
ABSL Nifty 50Equal Weight8801
ABSL Nifty 50Rregular2002
ABSL Nifty 50Growth1903
ICICI Prudential US BluechipGrowth3241
ICICI Prudential US BluechipRegular3212
ICICI Prudential US BluechipEqual Weight2443
ICICI Prudential US BluechipFinance1234
ICICI Prudential US BluechipInfra1205

 

Please help!

1 ACCEPTED SOLUTION
v-chenwuz-msft
Community Support
Community Support

Hi @Anonymous ,

 

Maybe you can try this measure:

rank = 
RANKX (
    CALCULATETABLE (
        VALUES ( 'Table'[Category] ),
        ALLSELECTED ( 'Table'[Category] )
    ),
    CALCULATE ( SUM ( 'Table'[YTD Sales In CR] ) )
)

 

Result:

vchenwuzmsft_0-1656408492556.png

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

3 REPLIES 3
v-chenwuz-msft
Community Support
Community Support

Hi @Anonymous ,

 

Maybe you can try this measure:

rank = 
RANKX (
    CALCULATETABLE (
        VALUES ( 'Table'[Category] ),
        ALLSELECTED ( 'Table'[Category] )
    ),
    CALCULATE ( SUM ( 'Table'[YTD Sales In CR] ) )
)

 

Result:

vchenwuzmsft_0-1656408492556.png

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

worked like a beauty

ribisht17
Super User
Super User

@Anonymous 

 

Here is the solution,Solved: Rank with GroupBy - Microsoft Power BI Community

 

Regards,

Ritesh

Mark my post as a solution if it helped you| Munde and Kudis (Ladies and Gentlemen) I like your Kudos!! !!
My YT Channel Dancing With Data !! Connect on Linkedin !!Power BI for Tableau Users 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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