# Computation on aggregation fileds

**URL:** https://discuss.elastic.co/t/computation-on-aggregation-fileds/98320
**Category:** Kibana
**Created:** [August 25, 2017, 5:14am UTC](https://discuss.elastic.co/t/computation-on-aggregation-fileds/98320 "2017-08-25T05:14:54Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![sureshboiina](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sureshboiina/32/79183_2.png) [@sureshboiina](https://discuss.elastic.co/u/sureshboiina)
#### Post date: [August 25, 2017, 5:14am UTC](https://discuss.elastic.co/t/computation-on-aggregation-fileds/98320/1 "2017-08-25T05:14:54Z")

</div>

HI

**Input**  
state,days  
johar,2  
johar,1  
johar,3  
johar,7  
johar,6  
johar,12  
pk,2  
pk,4  
pk,9

have data as above from this want to compute fields like days which are \<=3 days and \<=10 days computed fields for that i created scripted fields like

**3 days** (painless)  
if (doc['days'].value \<= 3){  
return 1  
}

**10 days** (painless)  
if (doc['days'].value \<= 10){  
return 1  
}

**Able to get the 3days ,10days and total by using scripted fileds But need percentage as shown below that not able to figure out what is the way in kibana to achieve this?**

**Output**  
**state,Total(count),3days,% 3days,10days,%10days**  
johar,6,3, **3/6** ,5, **5/6**  
pk,2,1, **1/2** ,2, **2/2**

**Please can u guys say can we able to achieve this in kibana**

---

<div class="post-metadata">

### Author: ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)
#### Post date: [August 25, 2017, 5:47am UTC](https://discuss.elastic.co/t/computation-on-aggregation-fileds/98320/2 "2017-08-25T05:47:08Z")

</div>

it should be possible with timelion where you can do things like

```auto
 .es(metric=sum:3days), 
 .es(metric=sum:10days), 
 .es(metric=sum:3days).divide(.es(metric=count))
 ...

```

---

<div class="post-metadata">

### Author: ![sureshboiina](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sureshboiina/32/79183_2.png) [@sureshboiina](https://discuss.elastic.co/u/sureshboiina)
#### Post date: [August 25, 2017, 5:55am UTC](https://discuss.elastic.co/t/computation-on-aggregation-fileds/98320/3 "2017-08-25T05:55:24Z")

</div>

Hi,

ok we can do using timeline but i need based on **state** not on timeline.  
can we do any terms aggregation in timeline?

Thanks,

---

<div class="post-metadata">

### Author: ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)
#### Post date: [August 25, 2017, 7:17am UTC](https://discuss.elastic.co/t/computation-on-aggregation-fileds/98320/4 "2017-08-25T07:17:51Z")

</div>

unfortunately timelion is limited to time series

---

<div class="post-metadata">

### Author: ![sureshboiina](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sureshboiina/32/79183_2.png) [@sureshboiina](https://discuss.elastic.co/u/sureshboiina)
#### Post date: [August 25, 2017, 8:33am UTC](https://discuss.elastic.co/t/computation-on-aggregation-fileds/98320/5 "2017-08-25T08:33:25Z")

</div>

HI,

so there is no possibility to achieve this scenario?

Thanks

---

<div class="post-metadata">

### Author: ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)
#### Post date: [August 25, 2017, 8:37am UTC](https://discuss.elastic.co/t/computation-on-aggregation-fileds/98320/6 "2017-08-25T08:37:14Z")

</div>

not that i am aware of. with exception of timelion and time series visual builder which are both time based its not possible to calculate ratios.

---

<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: [September 22, 2017, 8:37am UTC](https://discuss.elastic.co/t/computation-on-aggregation-fileds/98320/7 "2017-09-22T08:37:53Z")

</div>

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