# Visualize some kind of rolling sum?

**URL:** https://discuss.elastic.co/t/visualize-some-kind-of-rolling-sum/195774
**Category:** Kibana
**Created:** [August 19, 2019, 4:04pm UTC](https://discuss.elastic.co/t/visualize-some-kind-of-rolling-sum/195774 "2019-08-19T16:04:42Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![cgmelastic](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@cgmelastic](https://discuss.elastic.co/u/cgmelastic)
#### Post date: [August 19, 2019, 4:04pm UTC](https://discuss.elastic.co/t/visualize-some-kind-of-rolling-sum/195774/1 "2019-08-19T16:04:42Z")

</div>

Okay, let's say I'm getting sporadic deliveries of something, approximately every 2-3 hours but sometimes 2 in quick succession, sometimes none for 8 hours, etc. Each time a delivery is made, the amount delivered is put in a document in elasticsearch.

Is it possible to create a graph that shows, over time, the sum of the amount of stuff delivered in the 24 hours previous to each point on the graph?

---

<div class="post-metadata">

### Author: ![alisongoryachev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alisongoryachev/32/111352_2.png) [@alisongoryachev](https://discuss.elastic.co/u/alisongoryachev)
#### Post date: [August 19, 2019, 4:55pm UTC](https://discuss.elastic.co/t/visualize-some-kind-of-rolling-sum/195774/2 "2019-08-19T16:55:46Z")

</div>

Hi @cgmelastic!

What if you create a visualization where the x-axis is a [date histogram aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html) on the time field, with a daily interval. Then, set the y-axis to the [sum](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/search-aggregations-metrics-sum-aggregation.html#search-aggregations-metrics-sum-aggregation) of a given field. Would that give you what you're looking for?

---

<div class="post-metadata">

### Author: ![cgmelastic](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@cgmelastic](https://discuss.elastic.co/u/cgmelastic)
#### Post date: [August 19, 2019, 5:49pm UTC](https://discuss.elastic.co/t/visualize-some-kind-of-rolling-sum/195774/3 "2019-08-19T17:49:34Z")

</div>

@alisongoryachev , to be completely transparent, I am not 100% sure what I'm looking for. I do actually already have a graph like you describe though:

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

But this shows me one datapoint per day, you can see it clearly when using a stepped line. What I want to see is not so much "sum per day", but a more granular view of how the sum over the past 24 hours changes throughout the day(s). I would like to be able to proactively identify periods of time like 2019-08-04 and 2019-08-05 (where sum dipped below 30) so I can take action. A graph with the current settings wouldn't show me a downward trend until that datapoint is registered on the graph for the day.

---

<div class="post-metadata">

### Author: ![alisongoryachev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alisongoryachev/32/111352_2.png) [@alisongoryachev](https://discuss.elastic.co/u/alisongoryachev)
#### Post date: [August 19, 2019, 8:11pm UTC](https://discuss.elastic.co/t/visualize-some-kind-of-rolling-sum/195774/4 "2019-08-19T20:11:48Z")

</div>

@cgmelastic ah ok, I'm following now. I think what you might be looking for then is the [cumulative sum aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-cumulative-sum-aggregation.html#search-aggregations-pipeline-cumulative-sum-aggregation).

---

<div class="post-metadata">

### Author: ![cgmelastic](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@cgmelastic](https://discuss.elastic.co/u/cgmelastic)
#### Post date: [August 20, 2019, 3:01pm UTC](https://discuss.elastic.co/t/visualize-some-kind-of-rolling-sum/195774/5 "2019-08-20T15:01:01Z")

</div>

@alisongoryachev, I think this is closer to what I want. I definitely see a cumulative graph, but it's over all time, and just keeps increasing:

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

What I want to see is, instead of all time, it being cumulative only over a shifting window of about 24 hours previous to each data point, so the line would probably go up to and then hover around 30, at least in a view showing the past few weeks. Is that possible?

---

<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: [September 17, 2019, 3:01pm UTC](https://discuss.elastic.co/t/visualize-some-kind-of-rolling-sum/195774/6 "2019-09-17T15:01:06Z")

</div>

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