Math.round in JSON input

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"
}
}
}

}

}

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

1 Like

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