March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
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.
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.
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.
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.
Thank you for your assistance! This worked great, best wishes and be safe out there.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
124 | |
87 | |
85 | |
70 | |
51 |
User | Count |
---|---|
205 | |
153 | |
97 | |
79 | |
69 |