Get most recent distinct rows as kibana table

I created index pattern and it has 4 fields(timestamp,Id,Type,Count). Need to get the most recent(based on the timestamp)rows with unique Type.

Sample data:

|timestamp|ID|Type|Count|

|1/10/2022|1|A|12|
|1/11/2022|2|A|13|
|1/12/2022|3|A|2|
|1/13/2022|3|C|4|
|1/14/2022|1|C|8|
|1/15/2022|5|B|9|
|1/16/2022|3|D|0|
|1/17/2022|1|B|4|
|1/18/2022|3|B|2|

Expected output:

|timestamp|ID|Type|Count|

|1/10/2022|1|A|12|
|1/13/2022|3|C|4|
|1/15/2022|5|B|9|
|1/16/2022|3|D|0|

After the ordering timestamp is descending order then I need to get the most recent unique Types with other fields.

Hi,

Here is an example.

Use Terms aggregation with Max sub-aggregation on timestamp field for split rows Buckets.

Use Tophit Aggregation sort by timestamp.

2 Likes

Thanks a Mitani !!! you saved me !!!