# Script field - decimal multiplication is not working

**URL:** <https://discuss.elastic.co/t/script-field-decimal-multiplication-is-not-working/39117>\
**Category:** Kibana\
**Created:** [January 13, 2016, 2:27pm UTC](https://discuss.elastic.co/t/script-field-decimal-multiplication-is-not-working/39117 "2016-01-13T14:27:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![britto1981](https://avatars.discourse-cdn.com/v4/letter/b/a6a055/32.png) [@britto1981](https://discuss.elastic.co/u/britto1981)\
**Post date:** [January 13, 2016, 2:27pm UTC](https://discuss.elastic.co/t/script-field-decimal-multiplication-is-not-working/39117/1 "2016-01-13T14:27:13Z")

</div>

Hi,  
Using Kibana UI, I created a new script field named "cpu\_util\_percnt". Value of this field will be calculated based on the following expression:  
doc['metric\_value\_number'].value\*100.00

Here, "metric value number" is an existing field with long data type.

In the "Discover" tab, I could find the new field "cpu\_util\_percnt" and then selected it for performing a search. When I validated the search results, I noticed the following things as shown in the below table:

metric\_value\_number cpu\_util\_percnt  
1020 102000  
0.12 0  
2345 234500  
0.230 0

Here, we could find that the whole number multiplication works correctly and provides expected result. For example, 1020 \* 100 = 1020000. But, the decimal multiplication yields wrong results, i.e., 0.12\* 100 should results 12. But, it yields 0.

Kindly check and tell me how to correct the above things to achieve the expected result.

---

<div class="post-metadata">

**Author:** ![lukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas/32/6812_2.png) [@lukas](https://discuss.elastic.co/u/lukas)\
**Post date:** [January 13, 2016, 4:42pm UTC](https://discuss.elastic.co/t/script-field-decimal-multiplication-is-not-working/39117/2 "2016-01-13T16:42:51Z")

</div>

I just tried to replicate this issue and can't seem to. It seems to be working fine for me. Would you mind telling me what version of Kibana and Elasticsearch you're using?

---

<div class="post-metadata">

**Author:** ![britto1981](https://avatars.discourse-cdn.com/v4/letter/b/a6a055/32.png) [@britto1981](https://discuss.elastic.co/u/britto1981)\
**Post date:** [January 14, 2016, 6:30am UTC](https://discuss.elastic.co/t/script-field-decimal-multiplication-is-not-working/39117/3 "2016-01-14T06:30:29Z")

</div>

I am using the following things:

Elastic search 2.1.1  
Logstash 2.1.1  
Kibana 4.3.1

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [January 14, 2016, 6:46am UTC](https://discuss.elastic.co/t/script-field-decimal-multiplication-is-not-working/39117/4 "2016-01-14T06:46:04Z")

</div>

If the field is mapped as long, why are you storing values with decimal points in it?

---

<div class="post-metadata">

**Author:** ![britto1981](https://avatars.discourse-cdn.com/v4/letter/b/a6a055/32.png) [@britto1981](https://discuss.elastic.co/u/britto1981)\
**Post date:** [January 14, 2016, 7:17am UTC](https://discuss.elastic.co/t/script-field-decimal-multiplication-is-not-working/39117/5 "2016-01-14T07:17:43Z")

</div>

Hi Sorry. In Kibana field settings, it shows that the field "metric value number" has the data type of "number". I incorrectly specified as Long. The other field "cpu\_util\_percnt" where we are trying to store the expression result also a number data type field.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [January 14, 2016, 8:38am UTC](https://discuss.elastic.co/t/script-field-decimal-multiplication-is-not-working/39117/6 "2016-01-14T08:38:51Z")

</div>

What does the mapping in Elasticsearch say about the mapping for the field?

---

<div class="post-metadata">

**Author:** ![britto1981](https://avatars.discourse-cdn.com/v4/letter/b/a6a055/32.png) [@britto1981](https://discuss.elastic.co/u/britto1981)\
**Post date:** [January 14, 2016, 8:58am UTC](https://discuss.elastic.co/t/script-field-decimal-multiplication-is-not-working/39117/7 "2016-01-14T08:58:48Z")

</div>

I like to convey one thing. In Elastic search, the field type is "long". The type of the same field in Kibana is Number.

---

<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:** [July 6, 2017, 2:05pm UTC](https://discuss.elastic.co/t/script-field-decimal-multiplication-is-not-working/39117/8 "2017-07-06T14:05:03Z")

</div>


