# Kibana Line Chart - Average - Limit input to range or min/max

**URL:** <https://discuss.elastic.co/t/kibana-line-chart-average-limit-input-to-range-or-min-max/208667>\
**Category:** Kibana\
**Created:** [November 20, 2019, 9:56am UTC](https://discuss.elastic.co/t/kibana-line-chart-average-limit-input-to-range-or-min-max/208667 "2019-11-20T09:56:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bastian\_Jager](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bastian_jager/32/57892_2.png) [@Bastian\_Jager](https://discuss.elastic.co/u/Bastian_Jager)\
**Post date:** [November 20, 2019, 9:56am UTC](https://discuss.elastic.co/t/kibana-line-chart-average-limit-input-to-range-or-min-max/208667/1 "2019-11-20T09:56:35Z")

</div>

Hi,

looked now quiet a while though the forum, but without success. Only thing close was [Average Aggregation](https://discuss.elastic.co/t/average-aggregation/67826)

I am looking for a way to exclude values from averaging.

Lets say we have a line chart temperature over time. Temperature can go from -50 to 200. In case of errors the sensor value might be 65535. I still like to have the y axis adapted automatically to the current data range, but want to exclude the 65535 from the graph.  
Maybe the "JSON input" can do this, but I did not find documentation that helped me.

Thanks!

Kibana Version 7.3.1

---

<div class="post-metadata">

**Author:** ![bhavyarm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhavyarm/32/22392_2.png) [@bhavyarm](https://discuss.elastic.co/u/bhavyarm)\
**Post date:** [November 20, 2019, 3:08pm UTC](https://discuss.elastic.co/t/kibana-line-chart-average-limit-input-to-range-or-min-max/208667/2 "2019-11-20T15:08:12Z")

</div>

Hi,

Couple of things to note:  
This is an example of our JSON inpuy:  
**JSON Input**

A text field where you can add specific JSON-formatted properties to merge with the aggregation definition, as in the following example:

{ "script" : "doc['grade'].value \* 1.2" }

Also this is from our docs: In Elasticsearch releases 1.4.3 and later, this functionality requires you to enable [dynamic Groovy scripting](https://www.elastic.co/guide/en/elasticsearch/reference/7.4/modules-scripting.html).

[https://www.elastic.co/guide/en/kibana/current/metric-chart.html](https://www.elastic.co/guide/en/kibana/current/metric-chart.html)

This is another example: {"script" : { "source" : "if(doc['geo.src'] == 'CN') return 0; else return 1"}}

Let me know if it works.

Thanks,  
Bhavya

---

<div class="post-metadata">

**Author:** ![Bastian\_Jager](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bastian_jager/32/57892_2.png) [@Bastian\_Jager](https://discuss.elastic.co/u/Bastian_Jager)\
**Post date:** [November 21, 2019, 9:29am UTC](https://discuss.elastic.co/t/kibana-line-chart-average-limit-input-to-range-or-min-max/208667/3 "2019-11-21T09:29:35Z")

</div>

Hi Bhavya,

took me a moment to get it right, but yes, this works now in the 'JSON input' filed under Metrics \> Y-axis:

```
{"script" : { "source" : "if(doc['ir'].value < 100) return doc['ir'].value; else return 1"}}

```

(But only with your answer. I have to say, the the Elastic Documentation is something that only helps to find things that you once knew. It is not helpful to gain new knowledge.)

Thanks you!!

---

<div class="post-metadata">

**Author:** ![bhavyarm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhavyarm/32/22392_2.png) [@bhavyarm](https://discuss.elastic.co/u/bhavyarm)\
**Post date:** [November 21, 2019, 4:27pm UTC](https://discuss.elastic.co/t/kibana-line-chart-average-limit-input-to-range-or-min-max/208667/4 "2019-11-21T16:27:18Z")

</div>

That is very helpful feedback Bastian.

Will pass it on.

Thanks,  
Bhavya

---

<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:** [December 19, 2019, 4:27pm UTC](https://discuss.elastic.co/t/kibana-line-chart-average-limit-input-to-range-or-min-max/208667/5 "2019-12-19T16:27:26Z")

</div>

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