How to return the student with the highest grade for their class

alex1alex

Board Regular
Joined
Sep 12, 2014
Messages
57
Hi,
Starting with this:
O4NPsTL.png


I'd like to end up with this in PowerBI
7Urln5e.png



The calculated column for TopStudent should be something like:
Code:
=CALCULATE(FIRSTNONBLANK(Grades[Student],1),
                                    MAX(Grades[Grade],
                                    FILTER(Grades,Grades[Teacher]=Teachers[Teacher]))
                                    )
Look up the Topgrade of this rows teacher and then return the corresponding student's name.

As an aside, if I was just doing this in Excel/PowerPivot, I think I'd just do in a pivot table....but I want it in the DAX table since it's PowerBI.
The "TopGrade" column is:
Code:
=CALCULATE(MAX(Grades[Grade]),FILTER(Grades,Grades[Teacher]=Teachers[Teacher]))

The closest thing I've found it this but (obviously:() I can't figure it out. Fill Table with Last Survey Result - Excelerator BI

Many Thanks,
Alex
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
If you sure that each teacher has one top student only then you can use a next measure
Code:
Top Students = SUMMARIZE(FILTER('Grades';'Grades'[Grade] = MAX('Grades'[Grade])); Grades[Student])
But if top students are more. In Power BI and Excel 2016 we can use CONCATENATEX
Code:
Top Students=CONCATENATEX(
    SUMMARIZE(FILTER('Grades';'Grades'[Grade] = MAX('Grades'[Grade])); Grades[Student]);
    'Grades'[Student]; ", "
)
But I do not know how to do that in Excel 2013.
Regards,
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,638
Messages
6,120,676
Members
448,977
Latest member
moonlight6

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top