# Discrepancies when dividing a result using JSON input

**URL:** <https://discuss.elastic.co/t/discrepancies-when-dividing-a-result-using-json-input/165297>\
**Category:** Kibana\
**Created:** [January 22, 2019, 8:51pm UTC](https://discuss.elastic.co/t/discrepancies-when-dividing-a-result-using-json-input/165297 "2019-01-22T20:51:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![syunusic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/syunusic/32/4131_2.png) [@syunusic](https://discuss.elastic.co/u/syunusic)\
**Post date:** [January 22, 2019, 8:51pm UTC](https://discuss.elastic.co/t/discrepancies-when-dividing-a-result-using-json-input/165297/1 "2019-01-22T20:51:12Z")

</div>

I'm using Kibana 6.5.4 and I'm trying to create a simple metric..  
I want to sum inbound bites, so I create the metric, I use Sum as aggregation and in field I put the correct field ("server\_inbound\_bytes"). The result is correct, but is in bytes (13,198,284,718,586, for example).  
If I want to show it in GB, I'd devide it by 1024^3 (1073741824), so what I did is to use "JSON input" and there I write:  
"{ "script" : "doc['server\_inbound\_bytes'].value / 1073741824 "}"  
With that I'd expect to get 12,291, but I get 203.  
Any clues on where is the problem?  
My guess is that it divides by 1024^3 each single value (some of them are just a coupe of bytes and the result is taken as zero, and basically this an accumulated error.  
If that is the case, how should I do it in order to divide the final result (13,198,284,718,586) and not each value before to sum it?

---

<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 22, 2019, 11:42pm UTC](https://discuss.elastic.co/t/discrepancies-when-dividing-a-result-using-json-input/165297/2 "2019-01-22T23:42:26Z")

</div>

The easier solution for what you're trying to accomplish is probably just to use the "bytes" field formatter in the index pattern settings. Have you tried this?

---

<div class="post-metadata">

**Author:** ![syunusic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/syunusic/32/4131_2.png) [@syunusic](https://discuss.elastic.co/u/syunusic)\
**Post date:** [January 23, 2019, 7:05pm UTC](https://discuss.elastic.co/t/discrepancies-when-dividing-a-result-using-json-input/165297/3 "2019-01-23T19:05:02Z")

</div>

LOL. After 5 or 6 years using Kibana, this is the first time I change something in the field formatter.  
That did the trick.  
Thanks!  
Sacha.

---

<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:** [February 20, 2019, 7:05pm UTC](https://discuss.elastic.co/t/discrepancies-when-dividing-a-result-using-json-input/165297/4 "2019-02-20T19:05:03Z")

</div>

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