# Sum values before applying calculation

**URL:** https://discuss.elastic.co/t/sum-values-before-applying-calculation/103829
**Category:** Kibana
**Created:** [October 13, 2017, 6:11am UTC](https://discuss.elastic.co/t/sum-values-before-applying-calculation/103829 "2017-10-13T06:11:44Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![mathias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mathias/32/23176_2.png) [@mathias](https://discuss.elastic.co/u/mathias)
#### Post date: [October 13, 2017, 6:11am UTC](https://discuss.elastic.co/t/sum-values-before-applying-calculation/103829/1 "2017-10-13T06:11:44Z")

</div>

Hi,

I try to display a throughput graph over a time period of 7 days.  
To do this I need to set Interval in DateHistorogram to 600s.  
(Otherwise there are to many events. Kibana will complain)  
This will make the result 600 time greater than it should be.

To compensate for this I add formula in JSON input window for Y-axis where I sum the values.  
Unfortunately is the calculation done on each event instead of the sum of the time interval.  
This makes the result after calculation = 0. And then the sum of 0 is always 0

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

I wonder if it is possible to first sum all values over a timespan and then apply the calculation?

Br Mathias

---

<div class="post-metadata">

### Author: ![Bargs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bargs/32/5429_2.png) [@Bargs](https://discuss.elastic.co/u/Bargs)
#### Post date: [October 13, 2017, 4:21pm UTC](https://discuss.elastic.co/t/sum-values-before-applying-calculation/103829/2 "2017-10-13T16:21:19Z")

</div>

You should be able to do this in [Timelion](https://www.elastic.co/guide/en/kibana/current/timelion.html) or the new [Time Series](https://www.elastic.co/guide/en/kibana/current/time-series-visual-builder.html) visualization. It's not yet possible in the basic Kibana visualization editor.

---

<div class="post-metadata">

### Author: ![mathias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mathias/32/23176_2.png) [@mathias](https://discuss.elastic.co/u/mathias)
#### Post date: [October 14, 2017, 1:00am UTC](https://discuss.elastic.co/t/sum-values-before-applying-calculation/103829/3 "2017-10-14T01:00:07Z")

</div>

Thanks for your answer.

I have tried the new Time Series visualization but I do not know how to make sub aggregation.

I need to aggregate over time.  
Then I need to apply a filter.  
Then I need to split series to show one line per type.

It seems like after I have made a filter aggregation in the new visual builder I can not make another aggregation.  
Or at least I do not know how to do it and no one has been able to answer my question in this forum.

[https://discuss.elastic.co/t/several-groupings-using-visual-builder/100519/2](https://discuss.elastic.co/t/several-groupings-using-visual-builder/100519/2)

Timelion is too painful to maintain when you have many graphs.

Br Mathias

---

<div class="post-metadata">

### Author: ![Bargs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bargs/32/5429_2.png) [@Bargs](https://discuss.elastic.co/u/Bargs)
#### Post date: [October 16, 2017, 8:46am UTC](https://discuss.elastic.co/t/sum-values-before-applying-calculation/103829/4 "2017-10-16T08:46:50Z")

</div>

I don't have the answer off the top of my head, I'll have to ask around. Right now a lot of folks are traveling so it might take a few days, but I'll get back to you. It may be that it's not possible right now and we'll need to file an enhancement request.

---

<div class="post-metadata">

### Author: ![mathias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mathias/32/23176_2.png) [@mathias](https://discuss.elastic.co/u/mathias)
#### Post date: [October 19, 2017, 5:57am UTC](https://discuss.elastic.co/t/sum-values-before-applying-calculation/103829/5 "2017-10-19T05:57:50Z")

</div>

Hi Bargs,

Have you been able to find any answer from the experts?

Br Mathias

---

<div class="post-metadata">

### Author: ![simianhacker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simianhacker/32/3383_2.png) [@simianhacker](https://discuss.elastic.co/u/simianhacker)
#### Post date: [October 30, 2017, 5:01pm UTC](https://discuss.elastic.co/t/sum-values-before-applying-calculation/103829/6 "2017-10-30T17:01:11Z")

</div>

Instead of creating a filter aggregation in the "group by" section you can use the "panel filter" in the "Panel Options".

---

<div class="post-metadata">

### Author: ![mathias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mathias/32/23176_2.png) [@mathias](https://discuss.elastic.co/u/mathias)
#### Post date: [October 31, 2017, 10:32am UTC](https://discuss.elastic.co/t/sum-values-before-applying-calculation/103829/7 "2017-10-31T10:32:18Z")

</div>

Hi,

I understand what you mean. I add a common filter in Panel Options and the group by Terms in the "Group By" section.  
In panel filter I can add a filter common for all timeseries.  
That works for time series using the same filter.  
Unfortunately I have 4 time series with 4 different filters.

I think new functionality is needed to make Visual Builder complete.  
It would be good if adding new groupings could be as easy as it is in Grafana.

Br Mathias

---

<div class="post-metadata">

### Author: ![simianhacker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simianhacker/32/3383_2.png) [@simianhacker](https://discuss.elastic.co/u/simianhacker)
#### Post date: [October 31, 2017, 1:21pm UTC](https://discuss.elastic.co/t/sum-values-before-applying-calculation/103829/8 "2017-10-31T13:21:07Z")

</div>

So you want a filter per Series? I’ve been thinking about adding that for the last 2 months, let’s see what happens in the next couple of days 😉

---

<div class="post-metadata">

### Author: ![mathias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mathias/32/23176_2.png) [@mathias](https://discuss.elastic.co/u/mathias)
#### Post date: [October 31, 2017, 1:24pm UTC](https://discuss.elastic.co/t/sum-values-before-applying-calculation/103829/9 "2017-10-31T13:24:10Z")

</div>

If you can add this functionality you make me very happy.

Thanks in Advance.  
Mathias

---

<div class="post-metadata">

### Author: ![simianhacker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simianhacker/32/3383_2.png) [@simianhacker](https://discuss.elastic.co/u/simianhacker)
#### Post date: [October 31, 2017, 10:14pm UTC](https://discuss.elastic.co/t/sum-values-before-applying-calculation/103829/10 "2017-10-31T22:14:22Z")

</div>

Here is the PR I threaten to write: [https://github.com/elastic/kibana/pull/14696](https://github.com/elastic/kibana/pull/14696)

---

<div class="post-metadata">

### Author: ![mathias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mathias/32/23176_2.png) [@mathias](https://discuss.elastic.co/u/mathias)
#### Post date: [November 1, 2017, 6:35am UTC](https://discuss.elastic.co/t/sum-values-before-applying-calculation/103829/11 "2017-11-01T06:35:43Z")

</div>

Many thanks,

Any plans to tag it with 5.x.y?

Something completely different related to visual builder:  
Do you know if it would be easy to add a variable keeping track of used time interval (when time\_interval=auto) which could be used in formulas? This would make it possible to select different time span and use kibana's time interval=auto and get the correct result of sum values.

Kind regards  
Mathias

---

<div class="post-metadata">

### Author: ![simianhacker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simianhacker/32/3383_2.png) [@simianhacker](https://discuss.elastic.co/u/simianhacker)
#### Post date: [November 6, 2017, 2:06pm UTC](https://discuss.elastic.co/t/sum-values-before-applying-calculation/103829/12 "2017-11-06T14:06:21Z")

</div>

The only things getting back ported to 5.x is bug fixes. I will look into adding the interval to equations. 😃

---

<div class="post-metadata">

### Author: ![mathias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mathias/32/23176_2.png) [@mathias](https://discuss.elastic.co/u/mathias)
#### Post date: [November 6, 2017, 2:32pm UTC](https://discuss.elastic.co/t/sum-values-before-applying-calculation/103829/13 "2017-11-06T14:32:33Z")

</div>

Thanks a lot.

It would simplify things a lot if we make use of an interval variable.

Br Mathias

---

<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: [December 4, 2017, 2:33pm UTC](https://discuss.elastic.co/t/sum-values-before-applying-calculation/103829/14 "2017-12-04T14:33:07Z")

</div>

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