# Displaying the most recent data in graph

**URL:** https://discuss.elastic.co/t/displaying-the-most-recent-data-in-graph/289067
**Category:** Kibana
**Created:** [November 12, 2021, 12:37pm UTC](https://discuss.elastic.co/t/displaying-the-most-recent-data-in-graph/289067 "2021-11-12T12:37:04Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Ben\_Newton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ben_newton/32/97064_2.png) [@Ben\_Newton](https://discuss.elastic.co/u/Ben_Newton)
#### Post date: [November 12, 2021, 12:37pm UTC](https://discuss.elastic.co/t/displaying-the-most-recent-data-in-graph/289067/1 "2021-11-12T12:37:04Z")

</div>

Our product publishes posts to social media (Facebook, Twitter etc) and I'm trying to produce some graphs to analyse our data. What I'd like to show some graphs on how many posts publishes successfully vs how many fail to publish. At first I created created a pie chart with using the 'unique count' metric on the id field and split the slice using result.keyword field which is either 'failure' or 'success'. The problem with this is that a post can attempt to publish up to 3 times. So if a post only publishes on attempt 3 it's going be included in both the 'failure' segment and the 'success' segment of the chart'. Is there a way to count each post once?

Here is an example of my data for 1 post attempting to publish:

```auto
{
postID: 'abc-1',
channel: 'Facebook',
date: 2021-11-12T10:00:00.100Z,
severity: error,
message: 'post failed to published reason xyz'
result: 'failure'
}
{
postID: 'abc-1',
channel: 'Facebook',
date: 2021-11-12T10:00:00.200Z,
severity: error,
message: 'post failed to published reason xyz'
result: 'failure'
}
{
postID: 'abc-1',
channel: 'Facebook',
dateStamp: 2021-11-12T10:00:00.500Z,
severity: info,
message: 'post successfully published'
result: 'success'
}
{
postID: 'abc-2',
channel: 'Twitter',
date: 2021-11-12T10:30:00.000Z,
severity: info,
message: 'post successfully published'
result: 'success'
}
{
postID: 'abc-3',
channel: 'Facebook',
date: 2021-11-12T10:35:30.250Z,
severity: error,
message: 'post failed to published reason xyz'
result: 'failure'
}
{
postID: 'abc-3',
channel: 'Facebook',
dateStamp: 2021-11-12T10:35:30.500Z,
severity: info,
message: 'post successfully published'
result: 'success'
}

```

---

<div class="post-metadata">

### Author: ![Felix\_Roessel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felix_roessel/32/41623_2.png) [@Felix\_Roessel](https://discuss.elastic.co/u/Felix_Roessel)
#### Post date: [November 14, 2021, 9:43am UTC](https://discuss.elastic.co/t/displaying-the-most-recent-data-in-graph/289067/2 "2021-11-14T09:43:14Z")

</div>

What about adding the time window in your query?

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [November 14, 2021, 5:19pm UTC](https://discuss.elastic.co/t/displaying-the-most-recent-data-in-graph/289067/3 "2021-11-14T17:19:32Z")

</div>

[Here](https://discuss.elastic.co/t/time-series-datastore-altering/288478/4) is a similar question and some suggestions including excellent suggestion from our lens expert using latest value aggregation.

---

<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: [December 12, 2021, 5:19pm UTC](https://discuss.elastic.co/t/displaying-the-most-recent-data-in-graph/289067/4 "2021-12-12T17:19:59Z")

</div>

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