cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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.

Visit my LinkedIn page by clicking here.

Schedule a meeting with me to discuss further by clicking here.

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.

Visit my LinkedIn page by clicking here.

Schedule a meeting with me to discuss further by clicking here.

Frequent Visitor

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

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - August 2024

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

#### Fabric Community Update - August 2024

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

Top Solution Authors
Top Kudoed Authors