# Calculation Aggregation Kibana 5.4.0

**URL:** <https://discuss.elastic.co/t/calculation-aggregation-kibana-5-4-0/84780>\
**Category:** Kibana\
**Created:** [May 5, 2017, 8:40pm UTC](https://discuss.elastic.co/t/calculation-aggregation-kibana-5-4-0/84780 "2017-05-05T20:40:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MAXxATTAXx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maxxattaxx/32/8438_2.png) [@MAXxATTAXx](https://discuss.elastic.co/u/MAXxATTAXx)\
**Post date:** [May 5, 2017, 8:40pm UTC](https://discuss.elastic.co/t/calculation-aggregation-kibana-5-4-0/84780/1 "2017-05-05T20:40:37Z")

</div>

Hi, I been playing around with Kibana 5.4.0 new Visual Builder feature.

One of the aggregations i'm really curious about is the Calculation aggregation that allows you to run a Painless script and set variables. But i haven't found a way to get his working. Does anybody has an idea on how to use it currently.

I can even getting working by just returning the derivative i just calculated.

 ![](https://us1.discourse-cdn.com/elastic/original/3X/9/7/971c5af10e683224376c8cea33dd549316668000.png)

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

---

<div class="post-metadata">

**Author:** ![shaunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaunak/32/6643_2.png) [@shaunak](https://discuss.elastic.co/u/shaunak)\
**Post date:** [May 6, 2017, 2:09am UTC](https://discuss.elastic.co/t/calculation-aggregation-kibana-5-4-0/84780/2 "2017-05-06T02:09:18Z")

</div>

In the Script field, try `params.test` instead of `test`.

---

<div class="post-metadata">

**Author:** ![simianhacker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simianhacker/32/3383_2.png) [@simianhacker](https://discuss.elastic.co/u/simianhacker)\
**Post date:** [May 6, 2017, 2:14am UTC](https://discuss.elastic.co/t/calculation-aggregation-kibana-5-4-0/84780/3 "2017-05-06T02:14:02Z")

</div>

Also, you don't need the return statement.

---

<div class="post-metadata">

**Author:** ![MAXxATTAXx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maxxattaxx/32/8438_2.png) [@MAXxATTAXx](https://discuss.elastic.co/u/MAXxATTAXx)\
**Post date:** [May 8, 2017, 10:11pm UTC](https://discuss.elastic.co/t/calculation-aggregation-kibana-5-4-0/84780/4 "2017-05-08T22:11:36Z")

</div>

Nice. Thanks for the help 😀

---

<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:** [June 5, 2017, 10:20pm UTC](https://discuss.elastic.co/t/calculation-aggregation-kibana-5-4-0/84780/5 "2017-06-05T22:20:35Z")

</div>

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