# How to create max of serial difference in visualbuilder

**URL:** <https://discuss.elastic.co/t/how-to-create-max-of-serial-difference-in-visualbuilder/218869>\
**Category:** Kibana\
**Created:** [February 11, 2020, 9:57pm UTC](https://discuss.elastic.co/t/how-to-create-max-of-serial-difference-in-visualbuilder/218869 "2020-02-11T21:57:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anjilinga](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anjilinga/32/86010_2.png) [@anjilinga](https://discuss.elastic.co/u/anjilinga)\
**Post date:** [February 11, 2020, 9:57pm UTC](https://discuss.elastic.co/t/how-to-create-max-of-serial-difference-in-visualbuilder/218869/1 "2020-02-11T21:57:50Z")

</div>

i have data for every 15 mins with an incrimental data field. for rxample at 10:00 a.m. the value is 100 and at 10:15 the value is 130, at 10:30 the value 200 etc..  
I have to find the serial difference and need to draw a graph with the max value of serial diff for each day  
1 st day the max of serial difference is 80, for second day it is 90, for 3rd day 100,  
with these values need to draw a graph.

can u please suggest

---

<div class="post-metadata">

**Author:** ![nickofthyme](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickofthyme/32/60032_2.png) [@nickofthyme](https://discuss.elastic.co/u/nickofthyme)\
**Post date:** [February 15, 2020, 12:43am UTC](https://discuss.elastic.co/t/how-to-create-max-of-serial-difference-in-visualbuilder/218869/2 "2020-02-15T00:43:11Z")

</div>

Hey @anjilinga,

From what I understand, you are trying to create a graph depicting a [Serial Differencing Aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-serialdiff-aggregation.html#search-aggregations-pipeline-serialdiff-aggregation).

The best way to do so would be in the [`timelion`](https://www.elastic.co/blog/timelion-tutorial-from-zero-to-hero) visualization. In `timelion` you can provide an offset using the timelion expression language.

For example, if I were to take the serial difference between each day over time using an `offset`. The expression might look something like this 👇 (i.e. `f(x) = f(xt) - f(xt-n)`).

```auto
.es(index=kibana_sample_data_logs).mvavg(1d).subtract(
.es(index=kibana_sample_data_logs, offset=-1d).mvavg(1d))

```

Then setting the `interval` to `1d`. This would give me a graph looking something like this 👇

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/8/e88ca7dabca7ac18ecef0703e53dc3a31fffa556.png)

> You can adjust the `mvavg` to smooth out the curve.

---

<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:** [March 14, 2020, 12:43am UTC](https://discuss.elastic.co/t/how-to-create-max-of-serial-difference-in-visualbuilder/218869/3 "2020-03-14T00:43:21Z")

</div>

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