# Math operations

**URL:** <https://discuss.elastic.co/t/math-operations/122596>\
**Category:** Kibana\
**Created:** [March 5, 2018, 8:48pm UTC](https://discuss.elastic.co/t/math-operations/122596 "2018-03-05T20:48:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Danilo1](https://avatars.discourse-cdn.com/v4/letter/d/d2c977/32.png) [@Danilo1](https://discuss.elastic.co/u/Danilo1)\
**Post date:** [March 5, 2018, 8:48pm UTC](https://discuss.elastic.co/t/math-operations/122596/1 "2018-03-05T20:48:59Z")

</div>

Hi,

Is it possible to use one field aggregation in another field aggregation script?

I was looking for something like this  
(sum(quantity) / count(unique)) \* 60

---

<div class="post-metadata">

**Author:** ![jbudz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jbudz/32/45922_2.png) [@jbudz](https://discuss.elastic.co/u/jbudz)\
**Post date:** [March 7, 2018, 5:16pm UTC](https://discuss.elastic.co/t/math-operations/122596/2 "2018-03-07T17:16:27Z")

</div>

Generally speaking, it is with pipeline aggregations. Your use case would call for a bucket script aggregation, which is supported by TSVB. Timelion can do this as an extra processing layer.

TSVB:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/6/76303caf5d2750b43eee99883672e00ff7960eef.png)

Timelion:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/6/36e93bf02f7d205e3ad33f5617cdbb3ef08ae3f0.png)

---

<div class="post-metadata">

**Author:** ![lfroment-datasweet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lfroment-datasweet/32/32908_2.png) [@lfroment-datasweet](https://discuss.elastic.co/u/lfroment-datasweet)\
**Post date:** [March 8, 2018, 5:46pm UTC](https://discuss.elastic.co/t/math-operations/122596/3 "2018-03-08T17:46:58Z")

</div>

Hi,

we recently released a Kibana plugin that should do the job.  
Check it out there [https://github.com/datasweet-fr/kibana-datasweet-formula](https://github.com/datasweet-fr/kibana-datasweet-formula)

---

<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:** [April 5, 2018, 5:47pm UTC](https://discuss.elastic.co/t/math-operations/122596/4 "2018-04-05T17:47:07Z")

</div>

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