# Graph Sum based on average

**URL:** <https://discuss.elastic.co/t/graph-sum-based-on-average/46901>\
**Category:** Kibana\
**Created:** [April 10, 2016, 4:16pm UTC](https://discuss.elastic.co/t/graph-sum-based-on-average/46901 "2016-04-10T16:16:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pittoch](https://avatars.discourse-cdn.com/v4/letter/p/df788c/32.png) [@pittoch](https://discuss.elastic.co/u/pittoch)\
**Post date:** [April 10, 2016, 4:16pm UTC](https://discuss.elastic.co/t/graph-sum-based-on-average/46901/1 "2016-04-10T16:16:30Z")

</div>

Hi,

My indices have this records:

```
Name	Type	IO		
bay01	diskA	0		
bay01	diskA	20		
bay01	diskB	0		
bay01	diskB	40		
bay03	diskC	0		
bay03	diskC	10		
bay03	diskD	30		
bay03	diskD	60		

```

A. I need to graph an average on the IO value group by Type,Name:   
It's show:

```
Name	Type	Average IO	
bay01	diskA	10		
bay01	diskB	20		
bay02	diskC	5		
bay02	diskD	45		

```

I don't have problem to graph this value;

B. Then I need a second graph sum of IO group by Name   
But, this sum must use the average of the precedent graph.   
I need to have this value:

```
Name Sum IO based on Average Io
bay01 30		
bay02 50		

```

So in conclusion in this graph I need the sum of IO based on item average.

I don't find in Kibana how I can do that.   
The uniq possibility that i find is to do sum. But it show this result and not that I want.

```
Name Sum IO	
bay01 100		
bay02 80		

```

Help please! 🙂

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 10, 2016, 8:22pm UTC](https://discuss.elastic.co/t/graph-sum-based-on-average/46901/2 "2016-04-10T20:22:39Z")

</div>

You cannot currently do this. I think there is a issue on Github for it though!

---

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [April 11, 2016, 2:49pm UTC](https://discuss.elastic.co/t/graph-sum-based-on-average/46901/3 "2016-04-11T14:49:08Z")

</div>

I'm not sure why you would want to take the sum of the averages. It seems misleading. The average for bay01 is (0+20+0+40)/4 = 15 (which is also the average of 10 and 20 from part A). And you should be able to get that using Kibana.

---

<div class="post-metadata">

**Author:** ![pittoch](https://avatars.discourse-cdn.com/v4/letter/p/df788c/32.png) [@pittoch](https://discuss.elastic.co/u/pittoch)\
**Post date:** [April 12, 2016, 9:36pm UTC](https://discuss.elastic.co/t/graph-sum-based-on-average/46901/4 "2016-04-12T21:36:38Z")

</div>

> [@LeeDr](#):
>
> I'm not sure why you would want to take the sum of the averages. It seems misleading. The average for bay01 is (0+20+0+40)/4 = 15 (which is also the average of 10 and 20 from part A). And you should be able to get that using Kibana.

I don't need the average of bay01,

I need the average of DISKA, DISKB, DISKC, DISKD;

then the sum of disk/bay  
Sum of bay01 = diskA+diskB  
Sum of bay02 = diskC+diskD.

concretely , I need to calculate the IOs of a SAN datastore .  
For that I have to calculate IOs average for each datastore for a bay . Then I need to calculate the number of IOs of a storage array that is the sum of IOs / datastore.

---

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [April 13, 2016, 2:59pm UTC](https://discuss.elastic.co/t/graph-sum-based-on-average/46901/5 "2016-04-13T14:59:54Z")

</div>

OK, then I agree with Mark's earlier comment, it's not currently possible. In Kibana you can have multiple buckets for aggregation but they all use the same type of aggregation. You need to be able to switch them between Average and Sum.

A possible hack that might work, would be to create your visualization using either Sum or Average, and then go to the Settings -\> Objects, find your visualization, and edit the visState field. Right now I see there's just one "aggs" setting for 2 levels of buckets. You might be able to re-write that query so that one bucket used Sum and one used Average. And Kibana _might_ render the results correctly. No guarantees that it would work though. It might be best to test out the query using the Sense console.

---

<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, 1:56pm UTC](https://discuss.elastic.co/t/graph-sum-based-on-average/46901/6 "2017-07-06T13:56:13Z")

</div>


