# Last record for each unique value

**URL:** <https://discuss.elastic.co/t/last-record-for-each-unique-value/271077>\
**Category:** Kibana\
**Created:** [April 23, 2021, 11:21am UTC](https://discuss.elastic.co/t/last-record-for-each-unique-value/271077 "2021-04-23T11:21:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JeremyLoyd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jeremyloyd/32/93940_2.png) [@JeremyLoyd](https://discuss.elastic.co/u/JeremyLoyd)\
**Post date:** [April 23, 2021, 11:21am UTC](https://discuss.elastic.co/t/last-record-for-each-unique-value/271077/1 "2021-04-23T11:21:45Z")

</div>

Hello,

Our company changed to Elastic few months ago. before then we used to log a lot of things to one simple SQL table. in SQL i was able to find for each unique identifier last value that was recorded with simple Query. but as i wasn't trained in elastic\kibana magic I'm quite desperate.

Our company is working with lets call them "messages". Each message has its own UniqueID.  
logs in kibana looks like:

1. UniqueID=1,Event=MessageReceived, time
2. UniqueID=1, event=messageprocessing, time
3. uniqueID=1, event=finnished, time
4. UniqueID=2, event=messagereceived, time
5. UniqueID=2 event=messageprocessing, time

from time to time for some reasons our system didnt finnish the processing process and we have to find out what's wrong.

is there a way i can find what is the last event recorded for each uniqueID we have in last 24hour?? ive tried to google the poop of this but i wasnt able to find a solution that would work for me as i am inexperienced user of Elastic.

Thanks  
J.

---

<div class="post-metadata">

**Author:** ![Marta\_Bondyra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marta_bondyra/32/102122_2.png) [@Marta\_Bondyra](https://discuss.elastic.co/u/Marta_Bondyra)\
**Post date:** [April 23, 2021, 11:36am UTC](https://discuss.elastic.co/t/last-record-for-each-unique-value/271077/2 "2021-04-23T11:36:19Z")

</div>

Hi @JeremyLoyd,  
if you're using version 7.12 of Kibana, you could use Lens to create datatable visualization. Otherwise use the normal datatable.

Here's the example chart that might help you. CustomerId is an equivalent of uniqueId, product\_name.keyword is an equivalent of event. Let me know if I understood your problem correctly:

 ![Screenshot 2021-04-23 at 13.35.21](https://us1.discourse-cdn.com/elastic/original/3X/5/9/59c6cd5ae262e09f96a1ebd94f01281f0869c58d.png)

1. Setup your time picker to last 24 hours
2. Switch to datatable in chart picker on the top of the workspace
3. You can use top values aggregation on uniqueId and set up number of values really high (more than uniqueIds you're expecting to have)  
 ![Screenshot 2021-04-23 at 13.33.44](https://us1.discourse-cdn.com/elastic/original/3X/0/f/0f8128df7894127a6b8f148166848f7d7088d947.png)
4. Configure metric as last value on the event  
 ![Screenshot 2021-04-23 at 13.34.04](https://us1.discourse-cdn.com/elastic/original/3X/f/d/fd9a160e9d48fe294336911b1400f6c9e0f536bf.png)

---

<div class="post-metadata">

**Author:** ![JeremyLoyd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jeremyloyd/32/93940_2.png) [@JeremyLoyd](https://discuss.elastic.co/u/JeremyLoyd)\
**Post date:** [May 6, 2021, 11:11am UTC](https://discuss.elastic.co/t/last-record-for-each-unique-value/271077/3 "2021-05-06T11:11:15Z")

</div>

Hi Marta, thanks for reply & sorry for late response.

i cant really figure out how to add Rows and Metrics into Datatable options. all i got is Columns.  
Is it problem with our data types (string/number/record) or somewhere in my configuration or im i simply missing some plugin??

J.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 3, 2021, 11:11am UTC](https://discuss.elastic.co/t/last-record-for-each-unique-value/271077/4 "2021-06-03T11:11:33Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
