# Timelion greatest value so far

**URL:** https://discuss.elastic.co/t/timelion-greatest-value-so-far/172395
**Category:** Kibana
**Tags:** timelion
**Created:** [March 14, 2019, 5:03pm UTC](https://discuss.elastic.co/t/timelion-greatest-value-so-far/172395 "2019-03-14T17:03:06Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Kult](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kult/32/36877_2.png) [@Kult](https://discuss.elastic.co/u/Kult)
#### Post date: [March 14, 2019, 5:03pm UTC](https://discuss.elastic.co/t/timelion-greatest-value-so-far/172395/1 "2019-03-14T17:03:06Z")

</div>

Hi,

This is likely to be a niche case, but still wondering if there's a solution. Using Timelion, I'd like to find the greatest value _so far_.

Let's assume we have the following time series:  
Jan 1: 10  
Jan 2: 3  
Jan 3: 5  
Jan 4: 11  
Jan 5: 7  
Jan 6: 13  
Jan 7: 14  
Jan 8: 9  
Jan 9: 8

Using whatever greatest value so far algorithm there might be:  
On Jan 1, it should give 10;  
On Jan 2, it should give 10 as well because 10 \> 3;  
On Jan 3, it should give 10 as well because 10 \> 5;  
On Jan 4, it should give 11 because 11 \> 10;  
On Jan 5, it should give 11 as well because 11 \> 7;  
On Jan 6, it should give 13 because 13 \> 11;  
On Jan 7, it should give 14 because 14 \> 13;  
On Jan 8 and 9, it should give 14 because 14 \> 9 and 14 \> 8.

Best regards.

---

<div class="post-metadata">

### Author: ![joshdover](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joshdover/32/42020_2.png) [@joshdover](https://discuss.elastic.co/u/joshdover)
#### Post date: [March 14, 2019, 6:59pm UTC](https://discuss.elastic.co/t/timelion-greatest-value-so-far/172395/2 "2019-03-14T18:59:58Z")

</div>

Been playing around with this and I haven't found a way to do it with the existing Timelion functions. Basically you need something similar to `cusum` that would calculate the cumulative max.

The good news is, adding new function to Timelion is possible by adding a plugin. Here's a (bit outdated) [example](https://github.com/rashidkpc/timelion-random) and here's the [implementation of cusum](https://github.com/elastic/kibana/blob/master/src/legacy/core_plugins/timelion/server/series_functions/cusum.js#L55) which I imagine would only need subtle changes to become your own `cumax`.

If you get it working, we'd love a pull request upstream! If you're not a developer, [open an issue on the Kibana repo](https://github.com/elastic/kibana) and someone else may pick it up to add to a future Kibana version.

---

<div class="post-metadata">

### Author: ![Kult](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kult/32/36877_2.png) [@Kult](https://discuss.elastic.co/u/Kult)
#### Post date: [March 21, 2019, 12:48pm UTC](https://discuss.elastic.co/t/timelion-greatest-value-so-far/172395/3 "2019-03-21T12:48:58Z")

</div>

Hi Josh,

Thanks for the suggestion. Amending the cusum plugin has worked like a charm.  
I've created the pull request here [https://github.com/elastic/kibana/pull/33650](https://github.com/elastic/kibana/pull/33650)

Best regards,  
Albert.

---

<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: [April 18, 2019, 12:49pm UTC](https://discuss.elastic.co/t/timelion-greatest-value-so-far/172395/4 "2019-04-18T12:49:02Z")

</div>

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