The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance 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.
User | Count |
---|---|
80 | |
74 | |
41 | |
30 | |
28 |
User | Count |
---|---|
108 | |
96 | |
53 | |
48 | |
47 |