Forum Discussion
oscargushiken
4 years agoFrequent Visitor
Eliminate duplicate values based on earliest date and filtered by another column
Dear forum, I am attempting to issolate the distinct JOB_CODE values by the earliest date it appears in a row for each EMPLOYEE_ID. I have a data table that records employee events, such has cha...
- 4 years ago
Hi,
See if this M code works
let Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content], #"Changed Type" = Table.TransformColumnTypes(Source,{{"DATE", type datetime}, {"EMPLOYEE_ID", Int64.Type}, {"JOB_CODE", Int64.Type}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"EMPLOYEE_ID","JOB_CODE"}, {{"All", each Table.Max(_,"DATE")}}), #"Expanded All" = Table.ExpandRecordColumn(#"Grouped Rows", "All", {"DATE"}, {"DATE"}), #"Changed Type1" = Table.TransformColumnTypes(#"Expanded All",{{"DATE", type date}}), #"Sorted Rows" = Table.Sort(#"Changed Type1",{{"EMPLOYEE_ID", Order.Ascending}, {"DATE", Order.Descending}}) in #"Sorted Rows"Hope this helps.
oscargushiken
4 years agoFrequent Visitor
I am impressed, it worked!
Thank you so much.
Ashish_Mathur
Super User
4 years agoThank you. You are welcome.