# How to round to 2 digits after comma scripted field parameter value

**URL:** <https://discuss.elastic.co/t/how-to-round-to-2-digits-after-comma-scripted-field-parameter-value/282032>\
**Category:** Kibana\
**Created:** [August 20, 2021, 4:41am UTC](https://discuss.elastic.co/t/how-to-round-to-2-digits-after-comma-scripted-field-parameter-value/282032 "2021-08-20T04:41:34Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![arisxf](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arisxf](https://discuss.elastic.co/u/arisxf)\
**Post date:** [August 20, 2021, 4:41am UTC](https://discuss.elastic.co/t/how-to-round-to-2-digits-after-comma-scripted-field-parameter-value/282032/1 "2021-08-20T04:41:34Z")

</div>

Management/Index Patterns/{indexing}/scripted field  
 ![Screenshot from 2021-08-20 11-29-44](https://us1.discourse-cdn.com/elastic/original/3X/5/2/524b02a2a638f35e9e494e5d2360581b866ff56c.png)  
Visualize  
 ![Screenshot from 2021-08-20 11-30-46](https://us1.discourse-cdn.com/elastic/original/3X/6/d/6d35a50c9545ced0864cf6a83cc5bbcf22f0b252.png)  
Visualize  
 ![Screenshot from 2021-08-20 11-31-21](https://us1.discourse-cdn.com/elastic/original/3X/0/f/0ff6cf0cb2b9a8b91fe487a29dbca9c1b4efa412.png)

please all help

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [August 24, 2021, 3:29pm UTC](https://discuss.elastic.co/t/how-to-round-to-2-digits-after-comma-scripted-field-parameter-value/282032/2 "2021-08-24T15:29:09Z")

</div>

Go to "Stack Management" -\> "Index Patterns" and select your index pattern. Find your scripted field and edit. Check "Set format" and select "number". Then specify the number of digits you want to display.

> **[Manage index pattern data fields | Kibana Guide \[7.14\] | Elastic](https://www.elastic.co/guide/en/kibana/current/managing-index-patterns.html#managing-fields)**

---

<div class="post-metadata">

**Author:** ![arisxf](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arisxf](https://discuss.elastic.co/u/arisxf)\
**Post date:** [August 24, 2021, 6:08pm UTC](https://discuss.elastic.co/t/how-to-round-to-2-digits-after-comma-scripted-field-parameter-value/282032/3 "2021-08-24T18:08:16Z")

</div>

Hai @Nathan_Reese Thanks in advance for responding quickly, I've tried your suggestion but not working.

---

<div class="post-metadata">

**Author:** ![arisxf](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arisxf](https://discuss.elastic.co/u/arisxf)\
**Post date:** [August 24, 2021, 6:11pm UTC](https://discuss.elastic.co/t/how-to-round-to-2-digits-after-comma-scripted-field-parameter-value/282032/4 "2021-08-24T18:11:02Z")

</div>

because the scripted field is here not in the field

 ![Screenshot from 2021-08-25 01-08-06](https://us1.discourse-cdn.com/elastic/original/3X/c/5/c593fd1ff8bc5af195d0bf03155118221d142628.png)

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [August 24, 2021, 7:39pm UTC](https://discuss.elastic.co/t/how-to-round-to-2-digits-after-comma-scripted-field-parameter-value/282032/5 "2021-08-24T19:39:21Z")

</div>

What version of kibana are you using? You can format runtime fields, which are the replacement for scripted fields. Otherwise, you could updated your script to round the number for you

---

<div class="post-metadata">

**Author:** ![arisxf](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arisxf](https://discuss.elastic.co/u/arisxf)\
**Post date:** [August 25, 2021, 8:26am UTC](https://discuss.elastic.co/t/how-to-round-to-2-digits-after-comma-scripted-field-parameter-value/282032/6 "2021-08-25T08:26:41Z")

</div>

thanks again for your response, I use kibana:7.6.2

---

<div class="post-metadata">

**Author:** ![arisxf](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arisxf](https://discuss.elastic.co/u/arisxf)\
**Post date:** [August 25, 2021, 8:27am UTC](https://discuss.elastic.co/t/how-to-round-to-2-digits-after-comma-scripted-field-parameter-value/282032/7 "2021-08-25T08:27:34Z")

</div>

how to format runtime fields, which are the replacement for scripted fields ?

---

<div class="post-metadata">

**Author:** ![arisxf](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arisxf](https://discuss.elastic.co/u/arisxf)\
**Post date:** [September 2, 2021, 3:27am UTC](https://discuss.elastic.co/t/how-to-round-to-2-digits-after-comma-scripted-field-parameter-value/282032/8 "2021-09-02T03:27:40Z")

</div>

hi @Nathan_Reese , how to format runtime fields, which are the replacement for scripted fields ?

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [September 2, 2021, 1:05pm UTC](https://discuss.elastic.co/t/how-to-round-to-2-digits-after-comma-scripted-field-parameter-value/282032/9 "2021-09-02T13:05:25Z")

</div>

Runtime fields do not exist in 7.6.

You can either

- upgrade and use runtime fields and then create a field formatter to round your number as outlined in the documentation.
- update your scripted field to round the number as part of the script

---

<div class="post-metadata">

**Author:** ![arisxf](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arisxf](https://discuss.elastic.co/u/arisxf)\
**Post date:** [September 23, 2021, 6:32pm UTC](https://discuss.elastic.co/t/how-to-round-to-2-digits-after-comma-scripted-field-parameter-value/282032/10 "2021-09-23T18:32:00Z")

</div>

big thanks response @Nathan_Reese . after a long journey, I found a trick like this need to add metric datasweet  
 ![Screenshot from 2021-09-24 01-31-43](https://us1.discourse-cdn.com/elastic/original/3X/1/3/136fdfa982e6b822b81c91c884068ce9c7702e0e.png)

---

<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:** [October 21, 2021, 6:32pm UTC](https://discuss.elastic.co/t/how-to-round-to-2-digits-after-comma-scripted-field-parameter-value/282032/11 "2021-10-21T18:32:55Z")

</div>

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