Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I have a table as shown below and want it to be transformed to
Input
EID | StartDate | MGRID |
100884 | 3/1/2018 | 101516 |
100884 | 8/1/2022 | 76728 |
10077 | 6/12/2000 | 10080 |
102083 | 4/1/2018 | 82224 |
102083 | 5/2/2023 | 82224 |
102085 | 5/7/2018 | 15384 |
102086 | 5/7/2018 | 15384 |
102558 | 6/11/2018 | 76728 |
102558 | 12/11/2023 | 101516 |
102558 | 9/6/2022 | 24976 |
Output
EID | StartDate | MGRID |
100884 | 8/1/2022 | 76728 |
10077 | 6/12/2000 | 10080 |
102083 | 5/2/2023 | 82224 |
102085 | 5/7/2018 | 15384 |
102086 | 5/7/2018 | 15384 |
102558 | 12/11/2023 | 101516 |
For each employee, I only want to keep the latest start date.
I have seen several similar posts but just can't make this work. Can someone please help. I want to do this in Power Query Editor / M Query in Power BI
Regards,
-Debo
Solved! Go to Solution.
In Power Query, sort the date column in descending order, add an index column, then remove duplicates on Employee ID. Only the most recent item for each EID will stay.
Here is an example I did:
This is when I am on the sorted rows step:
This is when I am on the remove duplicate step:
Proud to be a Super User! | |
let
#"Grouped Table" = Table.Group(DATA, "EID", {"grp", each Table.Sort(_, {"StartDate", Order.Descending}){0}}),
#"Expanded grp" = Table.ExpandRecordColumn(#"Grouped Table", "grp", {"StartDate", "MGRID"}, {"StartDate", "MGRID"})
in
#"Expanded grp"
Calculated table is way more concise and elegant,
Expertise = List.Accumulate( {Days as from Today}, {Skills and Knowledge}, (Current, Everyday) => Current & Day.LearnAndPractise(Everyday) ) |
let
#"Grouped Table" = Table.Group(DATA, "EID", {"grp", each Table.Sort(_, {"StartDate", Order.Descending}){0}}),
#"Expanded grp" = Table.ExpandRecordColumn(#"Grouped Table", "grp", {"StartDate", "MGRID"}, {"StartDate", "MGRID"})
in
#"Expanded grp"
Calculated table is way more concise and elegant,
Expertise = List.Accumulate( {Days as from Today}, {Skills and Knowledge}, (Current, Everyday) => Current & Day.LearnAndPractise(Everyday) ) |
In Power Query, sort the date column in descending order, add an index column, then remove duplicates on Employee ID. Only the most recent item for each EID will stay.
Here is an example I did:
This is when I am on the sorted rows step:
This is when I am on the remove duplicate step:
Proud to be a Super User! | |
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
69 | |
68 | |
40 | |
29 | |
26 |
User | Count |
---|---|
88 | |
49 | |
45 | |
38 | |
37 |