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

View all the Fabric Data Days sessions on demand. View schedule

Reply
jerryr
New Member

Rows - Maximum Date

Hi -

I have a table and I woudl like to only keep the rows with the maximum date by a specific column.

Example:

Starting data : TableTransactions

DepartmentIDDateTransactionID
A01/31/2025123
A11/01/2025345
B10/10/2025543
B03/03/2025778
C10/01/2025127

 

Endingg data : TableTransactions

DepartmentIDDateTransactionID
A11/01/2025345
B10/10/2025543
C10/01/2025127

 



Any thoughts ? Appreciate it - Jerry

2 ACCEPTED SOLUTIONS
mdaatifraza5556
Super User
Super User

Hi @jerryr 

Can you please try the below DAX

I have created the measure using below dax .

Show Latest =
IF (
    MAX ( data[Date] ) =
        CALCULATE (
            MAX ( data[Date] ),
            ALLEXCEPT ( data, data[DepartmentID] )
        ),
    1,
    0
)
 
Create a table visual and add all the column u want in as it shows in your result

then click on the visual and then go for visual level filter ( Set Show Latest = 1).
 
Screenshot 2025-11-11 160215.png

 



If this answers your questions, kindly accpet it as a solution and give kudos.

View solution in original post

PhilipTreacy
Super User
Super User

Hi @jerryr 

 

Using Power Query/M you can do this with List.PositionOf to find the max date then extract the Date and Transaction ID.

 

First, Group By DepartmentID

 

PhilipTreacy_0-1762858773006.png

 

Then create a Custom Column and use this to get the Date

 

= [All][Date]{List.PositionOf([All][Date], List.Max([All][Date]))}

 

and another Custom Column for the TransactionID

 

= [All][TransactionID]{List.PositionOf([All][Date], List.Max([All][Date]))}

 

PhilipTreacy_2-1762859452567.png

 

 

Here's the full code and you can download it in this PBIX file

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Tc1RCsAgDAPQu/RbaNpa3O+2Y0jvfw07FRnkJzxCeqebCkHYhBXqWUSNoiwQYRyw6hOeD8CZDV7tAIwzG1q7Jrxrgd9Ho4gB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [DepartmentID = _t, Date = _t, TransactionID = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"DepartmentID", type text}, {"Date", type text}, {"TransactionID", Int64.Type}}),
    #"Changed Type with Locale" = Table.TransformColumnTypes(#"Changed Type", {{"Date", type date}}, "en-US"),
    #"Grouped Rows" = Table.Group(#"Changed Type with Locale", {"DepartmentID"}, {{"All", each _, type table [DepartmentID=nullable text, Date=nullable date, TransactionID=nullable number]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Date", each [All][Date]{List.PositionOf([All][Date], List.Max([All][Date]))}),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "TransactionID", each [All][TransactionID]{List.PositionOf([All][Date], List.Max([All][Date]))}),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"All"})
in
    #"Removed Columns"

 

Regards

 

Phil

 

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

7 REPLIES 7
v-prasare
Community Support
Community Support

Hi @jerryr,

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by community members for your issue worked for you or let us know if you need any further assistance?

 

 

 

 

Your feedback is important to us, Looking forward to your response

Thanks,

Prashanth

v-prasare
Community Support
Community Support

Hi @jerryr,

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by community members for your issue worked for you or let us know if you need any further assistance?

 

@Chewdata@m_dekorte@PhilipTreacy@Zanqueta, thanks for your prompt response

 

 

Your feedback is important to us, Looking forward to your response

Thanks,

Prashanth

 

Chewdata
Super User
Super User

Hey,

This method checks against the max date for that apartment ID and then for the largest Transaction ID. If there are multiple records for that date for that departmentID. If you remove the filter_TransactionID, you get filtering only on date.

 

let
    // replace YOURDATA with your source
    Source = YOURDATA,

    // select rows that match the Max date for that DepartmentID
    filter_maxDate = Table.SelectRows(
        Source, 
        each ([Date] = List.Max(Table.SelectRows(Source, (Row) => Row[DepartmentID] = _[DepartmentID])[Date]))
        ),

    // select rows that match the Max transactionID for the DepartmentID
    filter_maxTransactionID = Table.SelectRows(
        filter_maxDate, 
        each ([TransactionID] = List.Max(Table.SelectRows(filter_maxDate, (Row) => Row[DepartmentID] = _[DepartmentID])[TransactionID]))
        )
        
in
    filter_maxTransactionID

 

Hope this helps!
If any of these solutions helps you, please consider to give kudo's and accept an answer so other users with similar problems can find the answer quickly!

m_dekorte
Super User
Super User

Here's how you can lookup the record with max date, assuming there is only 1 row per date.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Tc1RCsAgDAPQu/RbaNpa3O+2Y0jvfw07FRnkJzxCeqebCkHYhBXqWUSNoiwQYRyw6hOeD8CZDV7tAIwzG1q7Jrxrgd9Ho4gB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [DepartmentID = _t, Date = _t, TransactionID = _t]),
    ChType = Table.TransformColumnTypes(Source,{{"DepartmentID", type text}, {"Date", type date}, {"TransactionID", Int64.Type}}, "en-US"),
    GroupRows = Table.Group(ChType, {"DepartmentID"}, {{"All", each _{[Date=List.Max([Date])]}, type [DepartmentID=nullable text, Date=nullable date, TransactionID=nullable number]}}),
    ExpandFields = Table.ExpandRecordColumn(GroupRows, "All", {"Date", "TransactionID"}, {"Date", "TransactionID"})
in
    ExpandFields

 

alternatively, this will get you all rows with the max date

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Tc1RCsAgDAPQu/RbaNpa3O+2Y0jvfw07FRnkJzxCeqebCkHYhBXqWUSNoiwQYRyw6hOeD8CZDV7tAIwzG1q7Jrxrgd9Ho4gB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [DepartmentID = _t, Date = _t, TransactionID = _t]),
    ChType = Table.TransformColumnTypes(Source,{{"DepartmentID", type text}, {"Date", type date}, {"TransactionID", Int64.Type}}, "en-US"),
    GroupRows = Table.Group(ChType, {"DepartmentID"}, {{"All", each Table.SelectRows(_, (x)=> x[Date]=List.Max([Date])), type table [DepartmentID=nullable text, Date=nullable date, TransactionID=nullable number]}}),
    ExpandFields = Table.ExpandTableColumn(GroupRows, "All", {"Date", "TransactionID"}, {"Date", "TransactionID"})
in
    ExpandFields

 

PhilipTreacy
Super User
Super User

Hi @jerryr 

 

Using Power Query/M you can do this with List.PositionOf to find the max date then extract the Date and Transaction ID.

 

First, Group By DepartmentID

 

PhilipTreacy_0-1762858773006.png

 

Then create a Custom Column and use this to get the Date

 

= [All][Date]{List.PositionOf([All][Date], List.Max([All][Date]))}

 

and another Custom Column for the TransactionID

 

= [All][TransactionID]{List.PositionOf([All][Date], List.Max([All][Date]))}

 

PhilipTreacy_2-1762859452567.png

 

 

Here's the full code and you can download it in this PBIX file

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Tc1RCsAgDAPQu/RbaNpa3O+2Y0jvfw07FRnkJzxCeqebCkHYhBXqWUSNoiwQYRyw6hOeD8CZDV7tAIwzG1q7Jrxrgd9Ho4gB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [DepartmentID = _t, Date = _t, TransactionID = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"DepartmentID", type text}, {"Date", type text}, {"TransactionID", Int64.Type}}),
    #"Changed Type with Locale" = Table.TransformColumnTypes(#"Changed Type", {{"Date", type date}}, "en-US"),
    #"Grouped Rows" = Table.Group(#"Changed Type with Locale", {"DepartmentID"}, {{"All", each _, type table [DepartmentID=nullable text, Date=nullable date, TransactionID=nullable number]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Date", each [All][Date]{List.PositionOf([All][Date], List.Max([All][Date]))}),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "TransactionID", each [All][TransactionID]{List.PositionOf([All][Date], List.Max([All][Date]))}),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"All"})
in
    #"Removed Columns"

 

Regards

 

Phil

 

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Zanqueta
Solution Supplier
Solution Supplier

Hello @jerryr,

You can also do this in the PowerQuery query editor using Table.Group function:

zanqueta001_0-1762858993352.png


Here my simulation script for your case:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Rc1LCsAwCATQu7gO+IuYbdtjBO9/jdpEUpiNvkHnhAsaKCMxConlwKIQbUNu+YB2W3B/JcJMgXU9QIqZAvex4KlT9P9wiHgB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [DepartmentID = _t, Date = _t, TransactionID = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"DepartmentID"}, {{"LastDate", each List.Max([Date]), type nullable date}, {"TransactionID", each List.Max([TransactionID]), type nullable text}})
in
    #"Grouped Rows"

 

If this response resolved your issue, please mark it as correct to assist other members of the community.

mdaatifraza5556
Super User
Super User

Hi @jerryr 

Can you please try the below DAX

I have created the measure using below dax .

Show Latest =
IF (
    MAX ( data[Date] ) =
        CALCULATE (
            MAX ( data[Date] ),
            ALLEXCEPT ( data, data[DepartmentID] )
        ),
    1,
    0
)
 
Create a table visual and add all the column u want in as it shows in your result

then click on the visual and then go for visual level filter ( Set Show Latest = 1).
 
Screenshot 2025-11-11 160215.png

 



If this answers your questions, kindly accpet it as a solution and give kudos.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.