# Using aggregation Json Input field to filter values

**URL:** <https://discuss.elastic.co/t/using-aggregation-json-input-field-to-filter-values/62259>\
**Category:** Kibana\
**Created:** [October 5, 2016, 10:57am UTC](https://discuss.elastic.co/t/using-aggregation-json-input-field-to-filter-values/62259 "2016-10-05T10:57:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbagatini](https://avatars.discourse-cdn.com/v4/letter/m/ec9cab/32.png) [@mbagatini](https://discuss.elastic.co/u/mbagatini)\
**Post date:** [October 5, 2016, 10:57am UTC](https://discuss.elastic.co/t/using-aggregation-json-input-field-to-filter-values/62259/1 "2016-10-05T10:57:24Z")

</div>

I'm trying to create a visualization on Kibana showing the average value of a field on a date histogram.  
In order to have a "smooth" average, I'd like to have a ceiling of 100 for said value.  
Using this json

{ "script": "ceil(100) ", "lang" : "groovy" }

the graph is ploted with all the values at 100. What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![mbagatini](https://avatars.discourse-cdn.com/v4/letter/m/ec9cab/32.png) [@mbagatini](https://discuss.elastic.co/u/mbagatini)\
**Post date:** [October 5, 2016, 11:28am UTC](https://discuss.elastic.co/t/using-aggregation-json-input-field-to-filter-values/62259/2 "2016-10-05T11:28:11Z")

</div>

It wasn't working because I was using the wrong method.  
This is the solution:

{ "script": "min(doc['field'].value, 100)", "lang" : "groovy" }

---

<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:** [October 7, 2016, 11:36pm UTC](https://discuss.elastic.co/t/using-aggregation-json-input-field-to-filter-values/62259/3 "2016-10-07T23:36:58Z")

</div>

Thanks for coming back and posting your solution!

---

<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:37pm UTC](https://discuss.elastic.co/t/using-aggregation-json-input-field-to-filter-values/62259/4 "2017-07-06T13:37:12Z")

</div>


