# How to avoid rounding for currency values?

**URL:** <https://discuss.elastic.co/t/how-to-avoid-rounding-for-currency-values/117535>\
**Category:** Kibana\
**Created:** [January 29, 2018, 9:20pm UTC](https://discuss.elastic.co/t/how-to-avoid-rounding-for-currency-values/117535 "2018-01-29T21:20:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fantast7](https://avatars.discourse-cdn.com/v4/letter/f/5daacb/32.png) [@fantast7](https://discuss.elastic.co/u/fantast7)\
**Post date:** [January 29, 2018, 9:20pm UTC](https://discuss.elastic.co/t/how-to-avoid-rounding-for-currency-values/117535/1 "2018-01-29T21:20:27Z")

</div>

I have loaded a JSON document into Elasticsearch with currency values. When I create a visualization with a sum aggregation each value is rounded down before creating the sum. How to avoid this?

Sample:  
1000  
1.99

Sum 1000 + 1 = 1001  
How can I get 1000 + 1.99 = 1001.99 ?

---

<div class="post-metadata">

**Author:** ![bhavyarm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhavyarm/32/22392_2.png) [@bhavyarm](https://discuss.elastic.co/u/bhavyarm)\
**Post date:** [January 29, 2018, 11:36pm UTC](https://discuss.elastic.co/t/how-to-avoid-rounding-for-currency-values/117535/2 "2018-01-29T23:36:53Z")

</div>

Hi,

Longs(1000 here) are integers and not floats. So this is something which you need to do when you are adding your data into Elasticsearch. When you are adding your first number - you need to add it formatted as double: [https://www.elastic.co/guide/en/elasticsearch/reference/current/number.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/number.html)

For example:

```auto
PUT foo/rocks/0
{
  "num": 1.99
}

PUT foo/rocks/1
{
  "num": 1000.00
}

```

After if you execute this, you will get:

```auto
GET foo/rocks/_search 
{
  "size": 0,
  "_source": {
    "excludes": []
  },
  "aggs": {
    "1": {
      "sum": {
        "field": "num"
      }
    }
  }
}

```

```auto
{
  "took": 4,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 2,
    "max_score": 0,
    "hits": []
  },
  "aggregations": {
    "1": {
      "value": 1001.9900000095367
    }
  }
}

```

Hope that helps.

Cheers,  
Bhavya

---

<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 26, 2018, 11:37pm UTC](https://discuss.elastic.co/t/how-to-avoid-rounding-for-currency-values/117535/3 "2018-02-26T23:37:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![xeraa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xeraa/32/48181_2.png) [@xeraa](https://discuss.elastic.co/u/xeraa)\
**Post date:** [November 22, 2018, 3:57pm UTC](https://discuss.elastic.co/t/how-to-avoid-rounding-for-currency-values/117535/4 "2018-11-22T15:57:17Z")

</div>

Building on the answer from [Wrong returned Values on simple SUM-Aggregation](https://discuss.elastic.co/t/wrong-returned-values-on-simple-sum-aggregation/156690/3), I have the following 3 documents in my dataset:

```auto
PUT sap-lo-po/_doc/1
{
  "EBELN": "4500017596",
  "EKPO": [
    {
      "NETWR": 149314.2
    }
  ]
}
PUT sap-lo-po/_doc/2
{
  "EBELN": "4500017596",
  "EKPO": [
    {
      "NETWR": 314.1
    }
  ]
}
PUT sap-lo-po/_doc/3
{
  "EBELN": "4500017596",
  "EKPO": [
    {
      "NETWR": 200
    }
  ]
}

```

I think the visualization based on this data is then correct:

 ![Kibana%202018-11-22%2016-56-22](https://us1.discourse-cdn.com/elastic/original/3X/9/6/9618d63b7d2b780083725407311fc29a8d34c632.png)
