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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
goatmonslc
Frequent Visitor

Groupby, allrows and min date

Hello,

 

I have been stuck on this for sevearl days and am now reaching out for help. I have a table with the structure as below:

goatmonslc_0-1729007941319.png

 

The result I'm looking for is:

 

goatmonslc_1-1729007969895.png

 

When I try group by, I am still getting duplicates instead of the row with the earliest "DateSubmitted". I need to see all the columns, with the earliest "DateSubmitted" for each recordID. I have tried "Basic" group by using RecordID, operation MIN, column DateSubmitted. That didn't work. I also tried Advanced group by, adding all columns except DateSubmitted to the grouping level - and then again, MIN of DateSubmitted. In each case, I'm getting duplicates.

 

Any help would be greatly appreciated as I've been stuck on this for days despite many attempts at different solutions!

2 ACCEPTED SOLUTIONS
m_dekorte
Super User
Super User

Hi @goatmonslc,

 

Try something like this:

let
    Source = YourTable,
    GroupRows = Table.Group(Source, {"RecordID"}, {{"t", each Table.Min(_, "DateSubmitted"), type [RecordID=nullable text, Project=nullable text, Description=nullable text, ReportType=nullable text, DateSubmitted=nullable date]}}),
    ExpandRec = Table.ExpandRecordColumn(GroupRows, "t", {"Project", "Description", "ReportType", "DateSubmitted"}, {"Project", "Description", "ReportType", "DateSubmitted"})
in
    ExpandRec

 

I hope this is helpful

View solution in original post

Omid_Motamedise
Super User
Super User

To resolve this issue, you can sort the table by the "Date Submitted" column in ascending order. Then, select both the "RecordID" and "Project" columns, right-click on one of them, and choose "Remove Duplicates."

However, be cautious—if you perform these steps separately, the sorting step will be ignored. To avoid this, you should either combine the steps as shown below or use the Table.Buffer function after sorting, before applying Table.RemoveDuplicates.

 

 



= Table.Distinct(Table.Sort(Source,{{"DateSubmitted", Order.Ascending}}), {"RecordID", "Project"})

 

 

If this answer helped resolve your issue, please consider marking it as the accepted answer. And if you found my response helpful, I'd appreciate it if you could give me kudos. 

Thank you!

If my answer helped solve your issue, please consider marking it as the accepted solution. It helps others in the community find answers faster—and keeps the community growing stronger!
You can also check out my YouTube channel for tutorials, tips, and real-world solutions in Power Query with the following link
https://youtube.com/@omidbi?si=96Bo-ZsSwOx0Z36h

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @goatmonslc ,

Thanks for m_dekorte's reply!
And @goatmonslc , I have tested m_dekorte's reply and it works perfectly!

vjunyantmsft_0-1729046840691.png

If m_dekorte's reply can help you to solve your problem, please accept m_dekorte's reply as solution so that more users can find the solution and learn faster, thanks!

Best Regards,
Dino Tao

Omid_Motamedise
Super User
Super User

To resolve this issue, you can sort the table by the "Date Submitted" column in ascending order. Then, select both the "RecordID" and "Project" columns, right-click on one of them, and choose "Remove Duplicates."

However, be cautious—if you perform these steps separately, the sorting step will be ignored. To avoid this, you should either combine the steps as shown below or use the Table.Buffer function after sorting, before applying Table.RemoveDuplicates.

 

 



= Table.Distinct(Table.Sort(Source,{{"DateSubmitted", Order.Ascending}}), {"RecordID", "Project"})

 

 

If this answer helped resolve your issue, please consider marking it as the accepted answer. And if you found my response helpful, I'd appreciate it if you could give me kudos. 

Thank you!

If my answer helped solve your issue, please consider marking it as the accepted solution. It helps others in the community find answers faster—and keeps the community growing stronger!
You can also check out my YouTube channel for tutorials, tips, and real-world solutions in Power Query with the following link
https://youtube.com/@omidbi?si=96Bo-ZsSwOx0Z36h

Thanks this worked like a charm!

m_dekorte
Super User
Super User

Hi @goatmonslc,

 

Try something like this:

let
    Source = YourTable,
    GroupRows = Table.Group(Source, {"RecordID"}, {{"t", each Table.Min(_, "DateSubmitted"), type [RecordID=nullable text, Project=nullable text, Description=nullable text, ReportType=nullable text, DateSubmitted=nullable date]}}),
    ExpandRec = Table.ExpandRecordColumn(GroupRows, "t", {"Project", "Description", "ReportType", "DateSubmitted"}, {"Project", "Description", "ReportType", "DateSubmitted"})
in
    ExpandRec

 

I hope this is helpful

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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 Kudoed Authors