# Sum by hour over several days

**URL:** <https://discuss.elastic.co/t/sum-by-hour-over-several-days/41947>\
**Category:** Kibana\
**Created:** [February 16, 2016, 10:33pm UTC](https://discuss.elastic.co/t/sum-by-hour-over-several-days/41947 "2016-02-16T22:33:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gautam\_S\_Thakur](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gautam_s_thakur/32/5156_2.png) [@Gautam\_S\_Thakur](https://discuss.elastic.co/u/Gautam_S_Thakur)\
**Post date:** [February 16, 2016, 10:33pm UTC](https://discuss.elastic.co/t/sum-by-hour-over-several-days/41947/1 "2016-02-16T22:33:26Z")

</div>

It looks like with kibana, this is not possible. It cannot perform summation of value over the same hour for multiple days.

I would like to sum a numeric field by hour, over an arbitrary time period say (last 10 days). The resulting plot looks likes below,

X-axis =\> hour of the day (0-23 or 8 am, 9 am.... ).  
Y-axis =\> aggregated sum (Say from last 10 days). Thus, value of y-axis for "0" hour is sum of all "0" hour in the last 10 days. That is, It is representative of the "sum of" all 8 AMs, 9 AMs... of last 10 days.

(X,Y) =\> (0, 10), (1, 20), ...... (23, 40) . An example is shown in the picture. I am using ES 1.7.1 and kibana 4.1.2

 ![](https://us1.discourse-cdn.com/elastic/original/2X/2/2992a47ec764212fbe0a6ff3114d1f52bd391743.png)

---

<div class="post-metadata">

**Author:** ![stormpython](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stormpython/32/7190_2.png) [@stormpython](https://discuss.elastic.co/u/stormpython)\
**Post date:** [February 19, 2016, 7:22am UTC](https://discuss.elastic.co/t/sum-by-hour-over-several-days/41947/2 "2016-02-19T07:22:28Z")

</div>

Gautam,

It is possible in 4.3 +. Essentially whenever scripted fields was introduced into Kibana. You can create a scripted field, called `hour_of_day`, as below.

 ![](https://us1.discourse-cdn.com/elastic/original/2X/7/7f9bc2cb0702176a49803dace7a94f2f456444ae.png)

To learn more about scripted fields in Kibana, see [here](https://www.elastic.co/blog/kibana-4-beta-3-now-more-filtery).

You can then create a line chart using a histogram aggregation to get the results you desire, like so:

 ![](https://us1.discourse-cdn.com/elastic/original/2X/1/174b80154caa1d089beec09df8e0b7be3bf41379.png)

---

<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 6, 2017, 2:01pm UTC](https://discuss.elastic.co/t/sum-by-hour-over-several-days/41947/3 "2017-07-06T14:01:46Z")

</div>


