# I am getting incorrect sum using aggregation from kibana visualization

**URL:** <https://discuss.elastic.co/t/i-am-getting-incorrect-sum-using-aggregation-from-kibana-visualization/230356>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-monitoring\
**Created:** [April 29, 2020, 11:03am UTC](https://discuss.elastic.co/t/i-am-getting-incorrect-sum-using-aggregation-from-kibana-visualization/230356 "2020-04-29T11:03:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RameshNagargoje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rameshnagargoje/32/30212_2.png) [@RameshNagargoje](https://discuss.elastic.co/u/RameshNagargoje)\
**Post date:** [April 29, 2020, 11:03am UTC](https://discuss.elastic.co/t/i-am-getting-incorrect-sum-using-aggregation-from-kibana-visualization/230356/1 "2020-04-29T11:03:05Z")

</div>

I am am having a document as shown in image

Mappning : ` "busyTime": { "type": "long" }`

 ![code_snippet](https://us1.discourse-cdn.com/elastic/original/3X/a/4/a424f9e43646d86fe67ad0450274d2a086a0f62b.png)

The above code snippet is an example.

On my actual production server, I am not getting the correct sum of the busy time, As per my understanding it is not considering float values it only add numbers before decimal only.

Why this is happening any help can be appreciable.

 ![kibana_snippet](https://us1.discourse-cdn.com/elastic/original/3X/9/2/923f6e91643675d1905263bab4303ecd4490248d.png)

````auto
[{
	"machinename":"Rama_desktop",
	"busyTime": 3.42,
	freeTime:20.58
	"location": "Beed"
	
},
{
	"machinename":"soni_desktop",
	"busyTime": 11.3,
	"freeTime": 12.7,
	"location": "Beed"
},
{
	"machinename":"raja_desktop",
	"busyTime": 22.8,
	"freeTime": 1.18,
	"location": "Beed"
}

]```
````

---

<div class="post-metadata">

**Author:** ![Luca\_Belluccini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luca_belluccini/32/33239_2.png) [@Luca\_Belluccini](https://discuss.elastic.co/u/Luca_Belluccini)\
**Post date:** [April 29, 2020, 12:41pm UTC](https://discuss.elastic.co/t/i-am-getting-incorrect-sum-using-aggregation-from-kibana-visualization/230356/2 "2020-04-29T12:41:41Z")

</div>

Given the fact you're using `long` as type of `busyTime`, the aggregation is done as `long`.

What you see in the document (e.g. `busyTime` of `3.42`) is the `_source`.

Aggregations are done on the type which got indexed.

You can see the indexed value doing:

```auto
GET <index name>/_search
{
  "docvalue_fields": ["busyTime"]
}

```

The best would be to reindex the data after fixing the type, which should be set to `float` or `half_float` (see [Elasticsearch numeric datatypes](https://www.elastic.co/guide/en/elasticsearch/reference/current/number.html#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:** [May 27, 2020, 12:57pm UTC](https://discuss.elastic.co/t/i-am-getting-incorrect-sum-using-aggregation-from-kibana-visualization/230356/3 "2020-05-27T12:57:13Z")

</div>

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