Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi Everyone,
I have the following data.
Student Name | Teacher | Grade |
Bob Smith | Phil Seger | 8th grade |
Bob Smith | Craig Steven | 9th grade |
Bob Smith | Teresa White | 10th grade |
Jim Doe | Larry Daniels | 8th grade |
Jim Doe | Roger Hall | 9th grade |
Jim Doe | Linda Lou | 10th grade |
I want to create an additional column with DAX that would pull the most recent teacher. Therefore, the table would look like:
Student Name | Teacher | Grade | Most Recent Teacher |
Bob Smith | Phil Seger | 8th grade | Teresa White |
Bob Smith | Craig Steven | 9th grade | Teresa White |
Bob Smith | Teresa White | 10th grade | Teresa White |
Jim Doe | Larry Daniels | 8th grade | Linda Lou |
Jim Doe | Roger Hall | 9th grade | Linda Lou |
Jim Doe | Linda Lou | 10th grade | Linda Lou |
How would I go about setting this up in DAX?
Solved! Go to Solution.
Hi,
Please check the below picture and the attached pbix file.
Hi,
You may download my PBI file from here.
Hope this helps.
@botaac in case you needed a measure
_mostRecentTeacher =
CALCULATE (
CALCULATE (
MAX ( t2[Teacher] ),
FILTER (
t2,
CONVERT ( SUBSTITUTE ( t2[Grade], "th grade", "" ), INTEGER )
= MAXX (
FILTER ( t2, EARLIER ( t2[Student Name] ) = t2[Student Name] ),
CONVERT ( SUBSTITUTE ( t2[Grade], "th grade", "" ), INTEGER )
)
)
),
ALLEXCEPT ( t2, t2[Student Name] )
)
Hi,
Please check the below picture and the attached pbix file.
Thank you for your assistance! This worked great, best wishes and be safe out there.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
71 | |
70 | |
43 | |
31 | |
26 |
User | Count |
---|---|
89 | |
49 | |
44 | |
38 | |
37 |