# Apply a script on an aggregation result in visualization

**URL:** <https://discuss.elastic.co/t/apply-a-script-on-an-aggregation-result-in-visualization/107052>\
**Category:** Kibana\
**Created:** [November 9, 2017, 2:08pm UTC](https://discuss.elastic.co/t/apply-a-script-on-an-aggregation-result-in-visualization/107052 "2017-11-09T14:08:16Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)\
**Post date:** [November 10, 2017, 10:46pm UTC](https://discuss.elastic.co/t/apply-a-script-on-an-aggregation-result-in-visualization/107052/4 "2017-11-10T22:46:02Z")

</div>

I see! Well, as I mentioned you can write a Painless script to perform changes to the values in your documents which will affect the end result of the aggregation. Here's an example of what I mean:

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

Here, I've defined a script which divides the "bytes" field value by 2 before it's aggregated. You can see the result in the 3rd column of the data table. Does this help? It's tough to give a more precise suggestion without knowing exactly the kind of script you need, but hopefully this provides a starting point.

CJ

---

_[View the full topic](https://discuss.elastic.co/t/apply-a-script-on-an-aggregation-result-in-visualization/107052)._
