# Max Calculation in TSVB over interval

**URL:** <https://discuss.elastic.co/t/max-calculation-in-tsvb-over-interval/214418>\
**Category:** Kibana\
**Created:** [January 9, 2020, 10:55am UTC](https://discuss.elastic.co/t/max-calculation-in-tsvb-over-interval/214418 "2020-01-09T10:55:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthias\_Seidl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matthias_seidl/32/60323_2.png) [@Matthias\_Seidl](https://discuss.elastic.co/u/Matthias_Seidl)\
**Post date:** [January 9, 2020, 10:55am UTC](https://discuss.elastic.co/t/max-calculation-in-tsvb-over-interval/214418/1 "2020-01-09T10:55:53Z")

</div>

Hi,  
I need to visualize the maximum value of a field during the last 10s. I have to use the TSVB for it (because later I need that value in a bucket script). But I'm having problems with the calculation.

 ![Screenshot 2020-01-09 at 11.51.52](https://us1.discourse-cdn.com/elastic/original/3X/9/1/91b5e6bf64034c017edba48fb02a6f06a81a64cd.png)

I'm using the Gauge visual (but it doesn't matter which one I'm using) and I set the timerange mode to last value and interval to 10s. But what happens now is, that every 10s the value jumps back to 0. It seems like it's not looking at the max value of the overall last 10 seconds but at the max value of the last 10s bucket. It's like it's opening ab a new bucket every 10s and is checking for the max value (that's why the value can only increase) and after 10s it resets to 0 and then it starts again increasing.

Is there a way around this behavior?

---

<div class="post-metadata">

**Author:** ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)\
**Post date:** [January 9, 2020, 10:11pm UTC](https://discuss.elastic.co/t/max-calculation-in-tsvb-over-interval/214418/2 "2020-01-09T22:11:34Z")

</div>

See if these panel options will help select the data properly for your guage:

- Panel options \> Data timerange mode: `Entire time range`
- Panel options \> Panel filter: `@timestamp: [now-10s/s TO now/s]` (no KQL)

Instead of aggregating into 10second buckets, this will filter the data to the documents with timestamps within the last 10 seconds.

---

<div class="post-metadata">

**Author:** ![Matthias\_Seidl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matthias_seidl/32/60323_2.png) [@Matthias\_Seidl](https://discuss.elastic.co/u/Matthias_Seidl)\
**Post date:** [January 9, 2020, 11:09pm UTC](https://discuss.elastic.co/t/max-calculation-in-tsvb-over-interval/214418/3 "2020-01-09T23:09:41Z")

</div>

Thank you very much Tim! That works like a charm.

---

<div class="post-metadata">

**Author:** ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)\
**Post date:** [January 10, 2020, 4:54pm UTC](https://discuss.elastic.co/t/max-calculation-in-tsvb-over-interval/214418/4 "2020-01-10T16:54:47Z")

</div>

Great!

---

<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:** [February 7, 2020, 4:54pm UTC](https://discuss.elastic.co/t/max-calculation-in-tsvb-over-interval/214418/5 "2020-02-07T16:54:51Z")

</div>

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