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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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.

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.

Any ideas how to tackle this?
1 ACCEPTED SOLUTION
Community Support

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:

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.

4 REPLIES 4
Community Support

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:

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.

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]))))

Helper I

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

## Helpful resources

Announcements

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

#### Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

#### Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors
Users online (1,586)