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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Anonymous
Not applicable

List the unique of most recent date based on a group

I am new to Power Query and needed some help. 

 

I have a quey table named trans_pmt_plan_pmts as shown here:

rpp1.png

 

I want to be able to get all the unique records based on hdr_id and pmt_plan_id and the most recent due_date and elimnate the records in red. 

 

The first example. pmt_plan_id 11646 oldet date is 2/15/2022, I need to delete all records where the pmt_planid is older than the current record and where the due_date is older than or equal to the due date. In this example pmt_plan_id has 3 records to be deleted because those due_dates are greater than or equal the 2/15/2022,

 

The second example pmt_plan_id 11700 oldest date is 2/28/2022, I need to delete the 3 records in red for the previous pmt_plan_id 11646 because the dates in red are greater than or equal to 2/28/2022

 

My end result shoul look like this:

rpp2.png

 

Any ideas how I can accomplish this in Power Query?

 

Regards,

Mike Ayuso

 

 

 

1 ACCEPTED SOLUTION
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

Here is one way, groupby to find the date then join back and filter out, but it can be slow if you have large dataset.  File attached for your reference, and btw, provide sample data in a format people can copy is more friendly

Vera_33_0-1654303891318.png

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thank you for your response and comment. This was my first post in this forum but will surely use your recomendation. Your solution is briliant and is exactly what I wanted. Thank you so much.

Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

Here is one way, groupby to find the date then join back and filter out, but it can be slow if you have large dataset.  File attached for your reference, and btw, provide sample data in a format people can copy is more friendly

Vera_33_0-1654303891318.png

 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors