Forum Discussion

numersoz's avatar
numersoz
Helper III
5 years ago
Solved

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: P...
  • Jimmy801's avatar
    5 years ago

    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

    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