Forum Discussion
ldoriejhl
2 years agoFrequent 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: Year ID Name 2021 1 AA 2021 2 BB...
- 2 years ago
Try this DAX code for the calculated column:
DAXMostRecentName = 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.