# Using json input to get absolute (positive) number

**URL:** <https://discuss.elastic.co/t/using-json-input-to-get-absolute-positive-number/121159>\
**Category:** Kibana\
**Created:** [February 23, 2018, 4:12am UTC](https://discuss.elastic.co/t/using-json-input-to-get-absolute-positive-number/121159 "2018-02-23T04:12:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dorj1234](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dorj1234/32/21339_2.png) [@dorj1234](https://discuss.elastic.co/u/dorj1234)\
**Post date:** [February 23, 2018, 4:12am UTC](https://discuss.elastic.co/t/using-json-input-to-get-absolute-positive-number/121159/1 "2018-02-23T04:12:56Z")

</div>

Hi,  
I have a metric that only makes sense as an absolute number.  
How can I turn a -5 to 5 using json input?  
Note that this doesn't work, I need the number to be positive when I get a 5 or a -5

```auto
{
"script": "_value * -1 "
}

```

Thanks !

---

<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:** [February 23, 2018, 3:44pm UTC](https://discuss.elastic.co/t/using-json-input-to-get-absolute-positive-number/121159/2 "2018-02-23T15:44:47Z")

</div>

You could create a scripted field with `Math.abs(doc['_value'].value)`

---

<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 23, 2018, 3:49pm UTC](https://discuss.elastic.co/t/using-json-input-to-get-absolute-positive-number/121159/3 "2018-03-23T15:49:00Z")

</div>

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