# How i could do this?

**URL:** <https://discuss.elastic.co/t/how-i-could-do-this/50794>\
**Category:** Kibana\
**Created:** [May 24, 2016, 7:18am UTC](https://discuss.elastic.co/t/how-i-could-do-this/50794 "2016-05-24T07:18:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ikerena](https://avatars.discourse-cdn.com/v4/letter/i/838e76/32.png) [@ikerena](https://discuss.elastic.co/u/ikerena)\
**Post date:** [May 24, 2016, 7:18am UTC](https://discuss.elastic.co/t/how-i-could-do-this/50794/1 "2016-05-24T07:18:58Z")

</div>

hello,  
i have a table in a database with information about infections in all the hosts of this network, and i have another table with the inventory.  
i wanna have the average of each (infected host of one type)/(total host of one type), for example, the infected windows 7 host/the total of windows 7 host.  
How i can do that?. and do a graphic with that?  
Thanks.

---

<div class="post-metadata">

**Author:** ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)\
**Post date:** [May 24, 2016, 9:11pm UTC](https://discuss.elastic.co/t/how-i-could-do-this/50794/2 "2016-05-24T21:11:36Z")

</div>

Kibana would need to support pipeline aggregations for this to be possible, which it does not right now as part of its core.

You could add a field to each document that has that divide calculation, and make any kind of visualization based on that field.

---

<div class="post-metadata">

**Author:** ![ikerena](https://avatars.discourse-cdn.com/v4/letter/i/838e76/32.png) [@ikerena](https://discuss.elastic.co/u/ikerena)\
**Post date:** [May 25, 2016, 9:13am UTC](https://discuss.elastic.co/t/how-i-could-do-this/50794/3 "2016-05-25T09:13:01Z")

</div>

thanks, and how i could divide two terms, for example infections on windows 7 hosts/number of hosts with windows 7?

---

<div class="post-metadata">

**Author:** ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)\
**Post date:** [May 25, 2016, 4:13pm UTC](https://discuss.elastic.co/t/how-i-could-do-this/50794/4 "2016-05-25T16:13:54Z")

</div>

If your data is time-based and you want a line chart with a moving ratio, then using the Timelion plugin for Kibana could be what you're looking for.

Otherwise, you can achieve this with a custom aggregation using a scripted metric aggregation: [https://www.elastic.co/guide/en/elasticsearch/reference/2.3/search-aggregations-metrics-scripted-metric-aggregation.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/search-aggregations-metrics-scripted-metric-aggregation.html) Note that you can't run this kind of aggregation from within Kibana, but you can take the output of that aggregation and write a program that creates a new index with the pre-comuted output data which will make it viewable from Kibana.

---

<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:52pm UTC](https://discuss.elastic.co/t/how-i-could-do-this/50794/5 "2017-07-06T13:52:19Z")

</div>


