Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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.
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
116 | |
101 | |
88 | |
35 | |
35 |
User | Count |
---|---|
152 | |
100 | |
83 | |
63 | |
54 |