# \[Feature\] Aggregation of 2 columns

**URL:** <https://discuss.elastic.co/t/feature-aggregation-of-2-columns/57876>\
**Category:** Kibana\
**Created:** [August 12, 2016, 3:34am UTC](https://discuss.elastic.co/t/feature-aggregation-of-2-columns/57876 "2016-08-12T03:34:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Summer\_nguyen](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@Summer\_nguyen](https://discuss.elastic.co/u/Summer_nguyen)\
**Post date:** [August 12, 2016, 3:34am UTC](https://discuss.elastic.co/t/feature-aggregation-of-2-columns/57876/1 "2016-08-12T03:34:10Z")

</div>

Hello,  
I'm new to Kibana and Elasticsearch, I used Kibana and Elastic Search for our log aggregation.  
My data is simple like this : id , time , username , spentGold , earnGold .  
I can make line charts :

- Total SpentGold hourly
- Total EarnGold hourly.

Now, I want to get a chart :

- ( Total EarnGold / Total SpentGold ) hourly.

Does Kibana support it now , how can I make it.  
Thank you very much.

Update 1 :  
in my any log rows : SpentGold and EarnGold can not be both positive numbers .  
if SpentGold \> 0, then EarnGold =0  
if EarnGold \>0 , then SpentGold =0  
SpentGold and EarnGold sometimes can be both = 0 .

---

<div class="post-metadata">

**Author:** ![tylersmalley](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tylersmalley/32/8833_2.png) [@tylersmalley](https://discuss.elastic.co/u/tylersmalley)\
**Post date:** [August 12, 2016, 5:18am UTC](https://discuss.elastic.co/t/feature-aggregation-of-2-columns/57876/2 "2016-08-12T05:18:04Z")

</div>

This can be done using a scripted field. The easiest way is to add on the index pattern under settings.

For example:

> doc['Total EarnGold'].value / doc['Total SpentGold'].value

---

<div class="post-metadata">

**Author:** ![Summer\_nguyen](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@Summer\_nguyen](https://discuss.elastic.co/u/Summer_nguyen)\
**Post date:** [August 12, 2016, 6:11am UTC](https://discuss.elastic.co/t/feature-aggregation-of-2-columns/57876/3 "2016-08-12T06:11:58Z")

</div>

Hello,  
Sorry about unclear data .  
in my any log rows : SpentGold and EarnGold can not be both positive numbers .  
if SpentGold \> 0, then EarnGold =0  
if EarnGold \>0 , then SpentGold =0

SpentGold and EarnGold sometimes can be both = 0 .  
So I can not make a scripted field like this way .  
I think there some kind of aggregation features in the visualize it self to calculate every hours.

Do you have any idea about it.  
Thank you very much,

---

<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:41pm UTC](https://discuss.elastic.co/t/feature-aggregation-of-2-columns/57876/4 "2017-07-06T13:41:16Z")

</div>


