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
Anonymous
Not applicable

Getting the max of a column group by another column

Greeting lovely member . 

i have the following Table that contain the student ID and their mark : 

Rfrikha1992_0-1624531740560.png

im trying to add a calculated Column that have "Max" on the max mark for each student but honestly im struggling :  . 

here the output that im looking for : 

Rfrikha1992_1-1624531924836.png

 

Thanks all in advance 🙂 

 

 

 

 

 

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

Hi @Anonymous ,

Try the following steps:

step1,use power query editor ,add a new  index column(you also could copy table then new table to to add  index):

vluwangmsft_0-1624870077961.png

Then use the following dax to create new column:

Max Mark = 
IF(
    RANKX (
        FILTER ( 'Table', 'Table'[Student ID] = EARLIER ( 'Table'[Student ID] ) ),
        'Table'[Mark],
        ,
        DESC,
        DENSE
    )=1,1,-999)+
    RANKX (
        FILTER ( 'Table', 'Table'[Student ID] = EARLIER ( 'Table'[Student ID] ) ),
        'Table'[Index],
        ,
        DESC,
        DENSE
    )
MAX Mark2 = IF(RANKX (
        FILTER ( 'Table', 'Table'[Student ID] = EARLIER ( 'Table'[Student ID] ) ),
       'Table'[Max Mark],
        ,
        DESC,
        DENSE
    )=1,"Max",BLANK())

 

vluwangmsft_1-1624871407495.png

 

Wish it is helpful for you!

 

Best Regards

Lucien

View solution in original post

6 REPLIES 6
v-luwang-msft
Community Support
Community Support

Hi @Anonymous ,

Try the following steps:

step1,use power query editor ,add a new  index column(you also could copy table then new table to to add  index):

vluwangmsft_0-1624870077961.png

Then use the following dax to create new column:

Max Mark = 
IF(
    RANKX (
        FILTER ( 'Table', 'Table'[Student ID] = EARLIER ( 'Table'[Student ID] ) ),
        'Table'[Mark],
        ,
        DESC,
        DENSE
    )=1,1,-999)+
    RANKX (
        FILTER ( 'Table', 'Table'[Student ID] = EARLIER ( 'Table'[Student ID] ) ),
        'Table'[Index],
        ,
        DESC,
        DENSE
    )
MAX Mark2 = IF(RANKX (
        FILTER ( 'Table', 'Table'[Student ID] = EARLIER ( 'Table'[Student ID] ) ),
       'Table'[Max Mark],
        ,
        DESC,
        DENSE
    )=1,"Max",BLANK())

 

vluwangmsft_1-1624871407495.png

 

Wish it is helpful for you!

 

Best Regards

Lucien

Anonymous
Not applicable

Thnaks all for your answers , all those answers works , but if there is 2 marks that are both have the Max values i will have "Max" for both of them . 

is there a way i can have Max only for 1 of them ? 
Thanks in advance 🙂 

@Anonymous 

You need to add an index column and modify create the calculated column as follows:

Max Marks = 

VAR __id = Table3[Studen ID]
var __max = MAXX(FILTER(Table3 , Table3[Studen ID] = __id ), Table3[Marks] + Table3[Index])
return
IF( (Table3[Marks] + Table3[Index]) = __max , "Max")

 

Fowmy_0-1624549551388.png

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Jihwan_Kim
Super User
Super User

 

https://www.dropbox.com/s/56yv2ibnjxklo4i/rfrikha.pbix?dl=0 

 

 

Max mark CC =
IF (
MAXX (
FILTER ( 'Table', 'Table'[StudentID] = EARLIER ( 'Table'[StudentID] ) ),
'Table'[Mark]
) = 'Table'[Mark],
"Max"
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Fowmy
Super User
Super User

@Anonymous 

Max Marks = 
IF(
    Table3[Marks] = 
    CALCULATE(
        MAX(Table3[Marks]),
        ALLEXCEPT(Table3 , Table3[Studen ID] )
    ),
    "Max"
)
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

amitchandak
Super User
Super User

@Anonymous , create a new column like

 


new column =
var _1 = maxx(filter(Table, [Student ID] = earlier([Student ID]) ),[MArks])
return
if( [MArks] =_1, "Max", blank())

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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