# Problem with "Last Value"

**URL:** https://discuss.elastic.co/t/problem-with-last-value/276268
**Category:** Kibana
**Created:** [June 17, 2021, 12:56pm UTC](https://discuss.elastic.co/t/problem-with-last-value/276268 "2021-06-17T12:56:17Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![LL\_FED](https://avatars.discourse-cdn.com/v4/letter/l/e47c2d/32.png) [@LL\_FED](https://discuss.elastic.co/u/LL_FED)
#### Post date: [June 17, 2021, 12:56pm UTC](https://discuss.elastic.co/t/problem-with-last-value/276268/1 "2021-06-17T12:56:17Z")

</div>

Hi,

for example:  
i want to show the **last value** of my Data: **State** in a metric aggregation.

I receive the documents in Kibana like this:

Doc 1:  
{  
"timestamp": ...,  
"state": 1  
}

Doc2:  
{  
"timestamp": ...,  
"room\_temperature": 25  
}

When Doc 1 is incoming my Metric aggregation is showing "1" ... so everything is perfect, but when the Doc2 is incoming, my "state" is set to "-".  
So all variables, that are not included in the last incoming document are set to "-".

How can I achieve that my metric "saves" the last value of "state" until it gets a new value?

Thank you!

---

<div class="post-metadata">

### Author: ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)
#### Post date: [June 17, 2021, 1:35pm UTC](https://discuss.elastic.co/t/problem-with-last-value/276268/2 "2021-06-17T13:35:01Z")

</div>

When using lens you can add a filter to last value like this: `state: *`. This will make sure the last document with a non-null value for state will be considered instead of the very last document.

---

<div class="post-metadata">

### Author: ![LL\_FED](https://avatars.discourse-cdn.com/v4/letter/l/e47c2d/32.png) [@LL\_FED](https://discuss.elastic.co/u/LL_FED)
#### Post date: [June 17, 2021, 2:25pm UTC](https://discuss.elastic.co/t/problem-with-last-value/276268/3 "2021-06-17T14:25:56Z")

</div>

Thanks,  
yeah why didn't i think about that.

---

<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: [July 15, 2021, 2:26pm UTC](https://discuss.elastic.co/t/problem-with-last-value/276268/4 "2021-07-15T14:26:18Z")

</div>

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