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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Filter only latest row for unique ID

Hi all, 

 

I need to filter for latest date results  per given ID in this table e.g. for ID = 1283273, I would like to see only row with 11/22/2020 6:50:18PM date. 

 

12.PNG

 

I have tried 

MaxDate =
CALCULATE(MAX(tablename[OrderDateTime]),FILTER(tablename,tablename[ID]=EARLIER(tablename[tablename])))
and
IsLatest = If([Date]=[MaxDate],"Latest","Older")
 
but above solution only worked for cases when each row will be on different day, not few rows within the same date.
 
13.PNG
 
Any ideas how to tackle this?
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Based on your description, you can create some calculated columns as follows.

MaxDate = CALCULATE(LASTNONBLANKVALUE('Fact'[OrderDateTime],MAX('Fact'[OrderDateTime])),ALLEXCEPT('Fact','Fact'[ID]))
Islatest = IF([OrderDateTime]=[MaxDate],"Latest","Older")

Result:

v-yuaj-msft_0-1613540893039.png

 

Hope that's what you were looking for.

Best Regards,

Yuna

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous ,

 

Based on your description, you can create some calculated columns as follows.

MaxDate = CALCULATE(LASTNONBLANKVALUE('Fact'[OrderDateTime],MAX('Fact'[OrderDateTime])),ALLEXCEPT('Fact','Fact'[ID]))
Islatest = IF([OrderDateTime]=[MaxDate],"Latest","Older")

Result:

v-yuaj-msft_0-1613540893039.png

 

Hope that's what you were looking for.

Best Regards,

Yuna

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

amitchandak
Super User
Super User

@Anonymous , Create a measure like this and use it with ID

 

calculate(Max(Table[OrderDateTime]), filter(Table, Table[OrderDateTime] = calculate(min(Table[OrderDateTime]), allexcept(Table, Table[ID]))))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

this is brilliant thank you!!

Anonymous
Not applicable

Thanks @amitchandak , 

 

I have created this measure per you suggestion and dropped into my table with IDs, but it shows blank so does seem to be working as expected. Otherwise, please explain what you mean by "...use it with ID..."

14.PNG

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.