Forum Discussion

jerryr0125's avatar
jerryr0125
New Member
9 months ago
Solved

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

9 Replies

    • jerryr0125's avatar
      jerryr0125
      New Member

      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

      • AlienSx's avatar
        AlienSx
        Super User
            Table.ExpandRecordColumn(
                Table.Group(
                    Source, 
                    "Department", 
                    {"x", (x) => Table.Max(x, "Date")}
                ), 
                "x", 
                {"Transaction ID", "Date"}
            )
  • Hi adding a step like Table.SelectRows(<your previous step>, each [Date] < Date.From("12/8/2025")) should work. 

  • 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"

  • v-aatheeque's avatar
    v-aatheeque
    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.

    • v-aatheeque's avatar
      v-aatheeque
      Community Support

      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.

  • Hi - none of these answers produce the outcome required - any thoughts ?