cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
archit_bansal
Regular Visitor

Get the subject in which students scored the max marks using DAX Power BI

Consider the Table below

IDSubjectMarks
1Maths75
1Science68
1English95
1Hindi83
1SST72
2Maths98
2Science72
2English90
2Hindi68
2SST70

 

Now i Need to find the subject in which student has scored max marks. Please help with DAX to achieve this
Expected Output

IDMax MarksSubject
195English
298Maths


 

1 ACCEPTED SOLUTION

Hi @archit_bansal 

You can try this,

create a measure

maxmarks = CALCULATE( MAX('Table'[Marks]),ALLEXCEPT('Table','Table'[ID]))

then create the table below,

output table = FILTER('Table','Table'[Marks]=[maxmarks])

result

vxiaotang_0-1652423035564.png

Best Regards,

Community Support Team _Tang

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

View solution in original post

4 REPLIES 4
archit_bansal
Regular Visitor

Thanks John what if i just need to get the subject in which student scored the max marks via measure

johnt75
Solution Sage
Solution Sage

You can do this with a couple of measures

Top Subject = CONCATENATEX( TOPN( 1, 'Table',  'Table'[Marks]), 'Table'[Subject], ", ")

Top Marks = MAX('Table'[Marks])

In case of ties this will return a comma separated list of subjects which shared the same top marks.

Thanks John what if i just need to get the subject in which student scored the max marks via measure

Hi @archit_bansal 

You can try this,

create a measure

maxmarks = CALCULATE( MAX('Table'[Marks]),ALLEXCEPT('Table','Table'[ID]))

then create the table below,

output table = FILTER('Table','Table'[Marks]=[maxmarks])

result

vxiaotang_0-1652423035564.png

Best Regards,

Community Support Team _Tang

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

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

Top Solution Authors
Top Kudoed Authors