# Math.round in JSON input

**URL:** <https://discuss.elastic.co/t/math-round-in-json-input/121075>\
**Category:** Elasticsearch\
**Created:** [February 22, 2018, 3:46pm UTC](https://discuss.elastic.co/t/math-round-in-json-input/121075 "2018-02-22T15:46:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mahbubur\_Rahman](https://avatars.discourse-cdn.com/v4/letter/m/5daacb/32.png) [@Mahbubur\_Rahman](https://discuss.elastic.co/u/Mahbubur_Rahman)\
**Post date:** [February 22, 2018, 3:46pm UTC](https://discuss.elastic.co/t/math-round-in-json-input/121075/1 "2018-02-22T15:46:52Z")

</div>

Hi,

I was wondering if I could use Math.round function in JSON input to suppress the number.

For an example,

6 --\> 5  
8 --\> 10  
etc.

I tried something like {"script": " Math.round(\_value/5)\*5"} for count, but not allowed!

I have managed to do that in API level, not in visualise JSON input. Any suggestion is appreciated.  
"aggs" : {  
"ccgs" : {  
"terms": {  
"field": "ccg.keyword",  
"size": 100  
},  
"aggs": {  
"test": {  
"cardinality": {  
"field": "\_id"  
}  
},  
"suppressed\_patient\_count":{  
"bucket\_script": {  
"buckets\_path": {  
"patient\_count" : "test"  
},  
"script": "params.patient\_count \> 2 ? Math.round(params.patient\_count/5)\*5 : Math.round((params.patient\_count+2)/5)\*5"  
}  
}  
}

```
}

```

}

---

<div class="post-metadata">

**Author:** ![Mahbubur\_Rahman](https://avatars.discourse-cdn.com/v4/letter/m/5daacb/32.png) [@Mahbubur\_Rahman](https://discuss.elastic.co/u/Mahbubur_Rahman)\
**Post date:** [February 28, 2018, 11:02am UTC](https://discuss.elastic.co/t/math-round-in-json-input/121075/2 "2018-02-28T11:02:44Z")

</div>

Hi, I was wondering if any of you came across this requirement and any suggestions will be appreciated.

---

<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:** [March 28, 2018, 11:02am UTC](https://discuss.elastic.co/t/math-round-in-json-input/121075/3 "2018-03-28T11:02:55Z")

</div>

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