Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
ldoriejhl
Frequent Visitor

Find the most recent value in a column

I'm working through a payroll file which features employee ID and name, and it includes instances where an employee name has changed, for example:

YearIDName
20211AA
20212BB
20213CC
20214DD
20221AA
20222BB
20223CE
20224DE
20231AA
20232BB
20233CE
20234DE

 

I am trying to figure out how to create a DAX column that would return only the most recent name for each employee ID, i.e. only the items at the end of the table. Any help appreciated on this one!

1 ACCEPTED SOLUTION
123abc
Community Champion
Community Champion

Try this DAX code for the calculated column:

 

DAX
MostRecentName = VAR LatestYear = CALCULATE( MAX(Table[Year]), ALLEXCEPT(Table, Table[ID]) ) RETURN CALCULATE( MAX(Table[Name]), Table[Year] = LatestYear, ALLEXCEPT(Table, Table[ID]) )
 
 
This will create a column called MostRecentName, which will display the most recent name for each employee based on the year. If you apply this to your data, it will show "CE" for employee ID 3 and "DE" for employee ID 4, based on the latest years in your table.

View solution in original post

2 REPLIES 2
Gabry
Super User
Super User

Hello @ldoriejhl ,

 

this is your formula:

 

Last Name =
Var _id = 'Table'[ID]
var _lyear= CALCULATE(MAX('Table'[Year]), 'Table'[ID]=_id, ALL('Table'))
return
CALCULATE(MAX('Table'[Name]), 'Table'[Year]=_lyear, 'Table'[ID]=_id, ALL('Table'))

Let me know if it works for you
123abc
Community Champion
Community Champion

Try this DAX code for the calculated column:

 

DAX
MostRecentName = VAR LatestYear = CALCULATE( MAX(Table[Year]), ALLEXCEPT(Table, Table[ID]) ) RETURN CALCULATE( MAX(Table[Name]), Table[Year] = LatestYear, ALLEXCEPT(Table, Table[ID]) )
 
 
This will create a column called MostRecentName, which will display the most recent name for each employee based on the year. If you apply this to your data, it will show "CE" for employee ID 3 and "DE" for employee ID 4, based on the latest years in your table.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors