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
Tob_P
Helper V
Helper V

Remove earliest or first instance of field in Power Query

Hi everyone,

 

Is there a way in Power Query whereby I can remove the earliest (or first) row of a table for each unique entry?

Tob_P_0-1708521161238.png

So for the first entry in this table based on Document No CQ0130449, I want to remove the one that has Date Sent of 17/05/2023 and repeat the process for each of the subsequent Doc Nos in the table?

 

Thanks

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

If you want only first row to be removed in each group, insert this step where Custom1 needs to be replaced with your previous step

= Table.Combine(Table.Group(Custom1, {"Document No_"}, {{"All", each Table.RemoveRows(_, 0)}})[All])

If you want to remove all rows which has same earliest date, then

able.Combine(Table.Group(Custom1, {"Document No_"}, {{"All", each Table.RemoveMatchingRows(_, {[Date Sent = List.Min(_[Date Sent])]}, "Date Sent")}})[All])

 

View solution in original post

3 REPLIES 3
Tob_P
Helper V
Helper V

Hi @Vijay_A_Verma I went for your first suggestion and that works perfectly for me, so thank you.

 

@m_dekorteAlso thank you, your response came in whilst I was trying the first suggestion out and I can see how that would also work.

 

Thanks again to the community for showing there's always more than one way to do something so I've learned two things today!

m_dekorte
Super User
Super User

Hi @Tob_P,

 

Your data appears to be sorted, try something like this:
1. Select the Document No column

2. Choose Group By, select the operation "All Rows" and specify a new column name, let's say "Temp"

3. In the formula bar you'll find this: {{"Temp", each _    (with some more code behind it...)

4. Replace: each _  With: each Table.RemoveFirstN(_, 1)

5. Use the Expand column option, to bring all data back.

 

When your data is not sorted you can nest a Table.Sort as well

I hope this is helpful

Vijay_A_Verma
Super User
Super User

If you want only first row to be removed in each group, insert this step where Custom1 needs to be replaced with your previous step

= Table.Combine(Table.Group(Custom1, {"Document No_"}, {{"All", each Table.RemoveRows(_, 0)}})[All])

If you want to remove all rows which has same earliest date, then

able.Combine(Table.Group(Custom1, {"Document No_"}, {{"All", each Table.RemoveMatchingRows(_, {[Date Sent = List.Min(_[Date Sent])]}, "Date Sent")}})[All])

 

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.