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
numersoz
Helper III
Helper III

Filter Max Value By Two Columns

Hi,

 

I have a transactions query with product ID and transaction date.

 

I want to filter the transaction date, so that it shows the latest transaction date for each product.

 

For example:

Product 1 1/1/2020

Product 1 1/2/2020

Product 2 1/5/2020

 

Will be converted to:

Product 1 1/2/2020

Product 2 1/5/2020

 

Where for each product, it only shows the row that has the max date.

 

I would like to do this in Power Query if possible, not DAX. Help will be appriciated.

 

 

1 ACCEPTED SOLUTION
Jimmy801
Community Champion
Community Champion

Hello @numersoz 

 

select your transaction column, and launch the group function. Select there your new name of the date, function max and your date column

image.png

Here is the code

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCijKTylNLlEwVNJRMjDUAyIjA6VYHUwJI3QJI4QOQ6wSxnpGRkqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Transaction = _t, Date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Transaction", type text}, {"Date", type date, "de-DE"}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Transaction"}, {{"Date", each List.Max([Date]), type date}})
in
    #"Grouped Rows"

Copy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

View solution in original post

3 REPLIES 3
Jimmy801
Community Champion
Community Champion

Hello @numersoz 

 

select your transaction column, and launch the group function. Select there your new name of the date, function max and your date column

image.png

Here is the code

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCijKTylNLlEwVNJRMjDUAyIjA6VYHUwJI3QJI4QOQ6wSxnpGRkqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Transaction = _t, Date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Transaction", type text}, {"Date", type date, "de-DE"}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Transaction"}, {{"Date", each List.Max([Date]), type date}})
in
    #"Grouped Rows"

Copy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

@Jimmy801  thank you this worked!

Anonymous
Not applicable

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCijKTylNLlEwVNJRMtQ31DcyMDJQitVBlzDClDACS5hCJWIB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Product = _t, date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Product", type text}, {"date", type date}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Product"}, {{"dates", each List.Max([date]), type nullable date}})
in
    #"Grouped Rows"

use above query

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