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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
jerryr0125
New Member

Power Query - Keep Rows based upon maximum date?

Hi -

I know there is a command in Power Query to 'keep rows', but is there a way to keep specific rows based upon the maximum date in the table ?

Example - transactiontable - start

 

DateTransaction ID
11/8/2025ABC
10/31/2025DEF
11/8/2025GHI
1/2/2025JKL



Example - transactiontable - end result

 

DateTransaction ID
11/8/2025ABC
11/8/2025GHI



I appreciate the help - thanks - jerryr

1 ACCEPTED SOLUTION
Nasif_Azam
Super User
Super User

Hey @jerryr0125 ,

 

Use the following M code that should full fill your requirements:

let
Source = transactiontable,
MaxDate = List.Max(Source[Date]),
FilteredRows = Table.SelectRows(Source, each [Date] = MaxDate)
in
FilteredRows  

 

Result:

Nasif_Azam_0-1762611066565.png

 

Also check the attached pbix file.

 

 

Best Regards,
Nasif Azam

 



Did I answer your question?
If so, mark my post as a solution!
Also consider helping someone else in the forums!

Proud to be a Super User!


LinkedIn

View solution in original post

7 REPLIES 7
v-aatheeque
Community Support
Community Support

Hi @jerryr0125 

Just checking in to see if the previous responses helped resolve your issue. If not, feel free to share your questions and we’ll be glad to assist.

Hi @jerryr0125 

We wanted to follow up to check if you’ve had an opportunity to review the previous responses. If you require further assistance, please don’t hesitate to let us know.

Nasif_Azam
Super User
Super User

Hey @jerryr0125 ,

 

Use the following M code that should full fill your requirements:

let
Source = transactiontable,
MaxDate = List.Max(Source[Date]),
FilteredRows = Table.SelectRows(Source, each [Date] = MaxDate)
in
FilteredRows  

 

Result:

Nasif_Azam_0-1762611066565.png

 

Also check the attached pbix file.

 

 

Best Regards,
Nasif Azam

 



Did I answer your question?
If so, mark my post as a solution!
Also consider helping someone else in the forums!

Proud to be a Super User!


LinkedIn

Hi - thank you for sharing - appreciate it!

 

what if I have a situation like this:

 

Table in Power Query (data) - Input

DepartmentTransaction IDDate
A3301/24/2025
A4403/01/2025
B7706/01/2025
B8807/01/2025
B3303/01/2025



Table in Power Query (data) - Output

DepartmentTransaction IDDate
A4403/01/2025
B8807/01/2025



I would like th create the table so that the latest data appears for each department . Any thoughts ? Thanks - Jerry

    Table.ExpandRecordColumn(
        Table.Group(
            Source, 
            "Department", 
            {"x", (x) => Table.Max(x, "Date")}
        ), 
        "x", 
        {"Transaction ID", "Date"}
    )
MasonMA
Community Champion
Community Champion

Hi,

 

if you wanted to tweak your M code in Query Editor, use below M code so that it gives you the result you expected.

 

let
// previous steps...
#"LastStep" = ...,

// add these two lines:
MaxDate = List.Max(#"LastStep"[Date]),
#"MaxDateRows" = Table.SelectRows(#"LastStep", each [Date] = MaxDate)
in
#"MaxDateRows"

DNMAF
Resolver III
Resolver III

Hi adding a step like Table.SelectRows(<your previous step>, each [Date] < Date.From("12/8/2025")) should work. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.