cancel
Showing results for
Did you mean:

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Frequent Visitor

## Input the most recent teacher with DAX

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?

1 ACCEPTED SOLUTION
Super User

Hi,

Please check the below picture and the attached pbix file.

Most Recent Teacher CC =
VAR currentstudent = Data[Student Name]
FILTER ( Data, Data[Student Name] = currentstudent ),
)
VAR newtable_teachername =
SUMMARIZE (
Data[Teacher]
)
RETURN
newtable_teachername

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.

4 REPLIES 4
Super User

Hi,

Hope this helps.

Regards,
Ashish Mathur
http://www.ashishmathur.com
Super User

@botaac  in case you needed a measure

``````_mostRecentTeacher =
CALCULATE (
CALCULATE (
MAX ( t2[Teacher] ),
FILTER (
t2,
= MAXX (
FILTER ( t2, EARLIER ( t2[Student Name] ) = t2[Student Name] ),
)
)
),
ALLEXCEPT ( t2, t2[Student Name] )
)``````

Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Super User

Hi,

Please check the below picture and the attached pbix file.

Most Recent Teacher CC =
VAR currentstudent = Data[Student Name]
FILTER ( Data, Data[Student Name] = currentstudent ),
)
VAR newtable_teachername =
SUMMARIZE (
Data[Teacher]
)
RETURN
newtable_teachername

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.

Frequent Visitor

Thank you for your assistance! This worked great, best wishes and be safe out there.

Announcements

#### Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

#### Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

#### Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors