DISTINCT won't help the OP, because there really aren't any distinct rows here.
I found a query that would solve the second case. I added 6 rows at the bottom that duplicate the max times for each asset, plus added an X variable. Here is the table:
![11335_parts1_duptimes.png 11335_parts1_duptimes.png](https://community.jmp.com/t5/image/serverpage/image-id/2950i4EDB1271EF954F76/image-size/medium?v=v2&px=400)
And here is the query that works (it requires one subquery and one subquery within a subquery)):
![11336_parts2_duptimes_query.png 11336_parts2_duptimes_query.png](https://community.jmp.com/t5/image/serverpage/image-id/2951iBF0D321BB3B2F1A6/image-size/medium?v=v2&px=400)
The custom expression is:
t1.Time = (SELECT MAX(tInner.Time) FROM parts tInner WHERE t1.Asset = tInner.Asset)
AND
t1.X = (SELECT MAX(tInner.X) FROM parts tInner WHERE t1.Asset = tInner.Asset AND
tInner.Time = (SELECT MAX(tInner2.Time) FROM parts tInner2 WHERE tInner.Asset = tInner2.Asset))
I capitalized all the SQL keywords to make it easier to read. I tried some simpler queries, but they did not work.
HTH,
Eric