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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
CEllis
Resolver I
Resolver I

Ranking using group and sum

Afternoon,

 

Is it possible to use a DAX statment to do ranking over a single table that resets at each change in grouping.

 

Source_Table

IdSubjectCycleResult
10Art134
11Art112
10Biology138
11Biology110
10French12
11French124
10Art223
11Art215
10Biology222
11Biology234
10French245
11French210

 

Outcome - The RANK column shows which id has the lowest figure in the subject,cycle group.

IdSubjectCycleResultRANK
10Art1342
11Art1121
10Biology1382
11Biology1101
10French121
11French1242
10Art2232
11Art2151
10Biology2221
11Biology2342
10French2452
11French2101

 

Many thanks

 

Chris

1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@CEllis , You can try below DAX

 

RANK =
RANKX(
FILTER(
Source_Table,
Source_Table[Subject] = EARLIER(Source_Table[Subject]) &&
Source_Table[Cycle] = EARLIER(Source_Table[Cycle])
),
Source_Table[Result],
,
ASC
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Thanks for the reply from @bhanu_gautam , please allow me to provide another insight: 

Hi  @CEllis ,

 

Here are the steps you can follow:

1. In Power Query – Transform -- Group.

Advanced – [Subject] and [Cycle]

Operation – All Rows

vyangliumsft_0-1717466198961.png

2. Add Column – Custom Column – Enter code.

Table.AddIndexColumn(
        Table.Sort([Row],{{"Result",
        Order.Ascending}}), "Row Rank",1,1)

vyangliumsft_1-1717466198965.png

3. Select [Custom] – [Rank] ,[ID] and [Row Rank].

vyangliumsft_2-1717466238401.png

4. Remove – [Row].

vyangliumsft_3-1717466238402.png

5. Result:

vyangliumsft_4-1717466267276.png

 

 

Best Regards,

Liu Yang

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

@Anonymous @bhanu_gautam Thankyou both for your support its much appreciated.

 

I can get the @Anonymous to work but can @bhanu_gautam be used in combination because I need to allow the same values to have the same rank number.

bhanu_gautam
Super User
Super User

@CEllis , You can try below DAX

 

RANK =
RANKX(
FILTER(
Source_Table,
Source_Table[Subject] = EARLIER(Source_Table[Subject]) &&
Source_Table[Cycle] = EARLIER(Source_Table[Cycle])
),
Source_Table[Result],
,
ASC
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Thanks @bhanu_gautam keep forgetting this needs to be a new column not measure to work.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

Top Solution Authors
Top Kudoed Authors