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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
debojyoty
Frequent Visitor

Help with grouping columns

I have a table as shown below and want it to be transformed to

 

Input

 

EIDStartDateMGRID
1008843/1/2018101516
1008848/1/202276728
100776/12/200010080
1020834/1/201882224
1020835/2/202382224
1020855/7/201815384
1020865/7/201815384
1025586/11/201876728
10255812/11/2023101516
1025589/6/202224976

 

Output

 

EIDStartDateMGRID
1008848/1/202276728
100776/12/200010080
1020835/2/202382224
1020855/7/201815384
1020865/7/201815384
10255812/11/2023101516

 

 

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

 

 

2 ACCEPTED SOLUTIONS
audreygerred
Super User
Super User

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:

audreygerred_0-1720727425580.png

This is when I am on the remove duplicate step:

audreygerred_1-1720727462952.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

ThxAlot
Super User
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"

ThxAlot_0-1720728950055.png

 

Calculated table is way more concise and elegant,

ThxAlot_1-1720729066804.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



View solution in original post

2 REPLIES 2
ThxAlot
Super User
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"

ThxAlot_0-1720728950055.png

 

Calculated table is way more concise and elegant,

ThxAlot_1-1720729066804.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



audreygerred
Super User
Super User

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:

audreygerred_0-1720727425580.png

This is when I am on the remove duplicate step:

audreygerred_1-1720727462952.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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