# Is it possible to apply aggrigate function on scripted fields in kibana? e-g Sum of product

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-apply-aggrigate-function-on-scripted-fields-in-kibana-e-g-sum-of-product/43775>\
**Category:** Kibana\
**Created:** [March 8, 2016, 1:23pm UTC](https://discuss.elastic.co/t/is-it-possible-to-apply-aggrigate-function-on-scripted-fields-in-kibana-e-g-sum-of-product/43775 "2016-03-08T13:23:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrizwan](https://avatars.discourse-cdn.com/v4/letter/m/f1d935/32.png) [@mrizwan](https://discuss.elastic.co/u/mrizwan)\
**Post date:** [March 8, 2016, 1:23pm UTC](https://discuss.elastic.co/t/is-it-possible-to-apply-aggrigate-function-on-scripted-fields-in-kibana-e-g-sum-of-product/43775/1 "2016-03-08T13:23:40Z")

</div>

I want to do this and generate a scripted field

SUM(doc['Field1'].value) /SUM( doc['Field2'].value)

is this possible in Kibana or any work around for this ?

---

<div class="post-metadata">

**Author:** ![Khalah\_Jones\_Golden](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/khalah_jones_golden/32/7169_2.png) [@Khalah\_Jones\_Golden](https://discuss.elastic.co/u/Khalah_Jones_Golden)\
**Post date:** [March 8, 2016, 2:25pm UTC](https://discuss.elastic.co/t/is-it-possible-to-apply-aggrigate-function-on-scripted-fields-in-kibana-e-g-sum-of-product/43775/2 "2016-03-08T14:25:44Z")

</div>

Hey mrizwan,

Sorry but I'm pretty sure it is not possible to do as you describe here. Scripted fields are applied after the aggregation. maybe you could apply the sum beforehand, though I need to do more research as to how you might go about that.

---

<div class="post-metadata">

**Author:** ![tbragin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tbragin/32/45166_2.png) [@tbragin](https://discuss.elastic.co/u/tbragin)\
**Post date:** [March 18, 2016, 1:12pm UTC](https://discuss.elastic.co/t/is-it-possible-to-apply-aggrigate-function-on-scripted-fields-in-kibana-e-g-sum-of-product/43775/3 "2016-03-18T13:12:45Z")

</div>

Khalah's right - this is not possible with Kibana scripted fields. However, if you install the Timelion plugin, its query language will allow stuff like that: [https://www.elastic.co/blog/timelion-timeline](https://www.elastic.co/blog/timelion-timeline)

---

<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:58pm UTC](https://discuss.elastic.co/t/is-it-possible-to-apply-aggrigate-function-on-scripted-fields-in-kibana-e-g-sum-of-product/43775/4 "2017-07-06T13:58:40Z")

</div>


