# Scripted field on Aggregated value

**URL:** <https://discuss.elastic.co/t/scripted-field-on-aggregated-value/87157>\
**Category:** Kibana\
**Created:** [May 25, 2017, 4:53pm UTC](https://discuss.elastic.co/t/scripted-field-on-aggregated-value/87157 "2017-05-25T16:53:50Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [May 26, 2017, 7:34pm UTC](https://discuss.elastic.co/t/scripted-field-on-aggregated-value/87157/2 "2017-05-26T19:34:25Z")

</div>

Hi Krishna,

Scripted fields work only on values within each individual doc. So if a doc had 3 numeric fields you could use a scripted field to add them together, or average them, or find the min, max, etc. But not across all docs or a set of docs.

But you can also use some scripting within Visualizations in the Advanced JSON field;

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

I don't know of very many exampels of using it, but here's one;

> [@Display concurrency in data on Kibana](https://discuss.elastic.co/t/display-concurrency-in-data-on-kibana/26006/13):
>
> It worked for me with the following data and config: curl -XPOST 'http://localhost:9200/test3' -d '{ "settings" : { "number\_of\_shards" : 1 }, "mappings" : { "test" : { "properties" : { "start\_date" : { "type" : "date"}, "end\_date" : { "type" : "date"}, "duration" : { "type" : "integer"} } } } }' curl -XPUT 'http://localhost:9200/test3/test/1' -d '{ "start\_date" : "2015-08-23T00:0…

Regards,  
Lee

---

_[View the full topic](https://discuss.elastic.co/t/scripted-field-on-aggregated-value/87157)._
