# How to get SUM of each category

**URL:** <https://discuss.elastic.co/t/how-to-get-sum-of-each-category/65230>\
**Category:** Kibana\
**Created:** [November 7, 2016, 1:37pm UTC](https://discuss.elastic.co/t/how-to-get-sum-of-each-category/65230 "2016-11-07T13:37:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![atanu\_panda](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@atanu\_panda](https://discuss.elastic.co/u/atanu_panda)\
**Post date:** [November 7, 2016, 1:37pm UTC](https://discuss.elastic.co/t/how-to-get-sum-of-each-category/65230/1 "2016-11-07T13:37:00Z")

</div>

"extras":{"responseTime":"123", "transaction\_type";"abc"}  
"extras":{"responseTime":"22", "transaction\_type";"abc"}  
"extras":{"responseTime":"456", "transaction\_type";"abc"}  
"extras":{"responseTime":"12", "transaction\_type";"xyz"}  
"extras":{"responseTime":"45", "transaction\_type";"xyz"}

Need bar chart with X-axis as transaction\_type (abc , xyz)  
and Y-axis as Total response time for each transaction\_type {xyz = (12+45), abc=(123+22+456)}

Please suggest. or send some tutorial

---

<div class="post-metadata">

**Author:** ![thomasneirynck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomasneirynck/32/23313_2.png) [@thomasneirynck](https://discuss.elastic.co/u/thomasneirynck)\
**Post date:** [November 7, 2016, 4:27pm UTC](https://discuss.elastic.co/t/how-to-get-sum-of-each-category/65230/2 "2016-11-07T16:27:42Z")

</div>

In the Bar-chart visualization page:

- use the "Sum"-metric in the Data-panel. It's in the drop downs. Select "responseTime" as the field you will sum.
- Your Y-axis would be a "Terms"-aggregation with "transaction\_type" as the field.

---

<div class="post-metadata">

**Author:** ![atanu\_panda](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@atanu\_panda](https://discuss.elastic.co/u/atanu_panda)\
**Post date:** [November 8, 2016, 1:35pm UTC](https://discuss.elastic.co/t/how-to-get-sum-of-each-category/65230/3 "2016-11-08T13:35:31Z")

</div>

Thanks for ur immediate reply.

Actually, i could not see these fields in the drop down, one of the reason might be these are not shown as indexed in the discover page. Not sure how we can index these fields.

Is it the values are of different type for the field across logs (for a given period of time).

Please suggest..

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [November 8, 2016, 1:38pm UTC](https://discuss.elastic.co/t/how-to-get-sum-of-each-category/65230/4 "2016-11-08T13:38:07Z")

</div>

Make sure your `responseTime` field is an integer. String fields can't be summed.

---

<div class="post-metadata">

**Author:** ![atanu\_panda](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@atanu\_panda](https://discuss.elastic.co/u/atanu_panda)\
**Post date:** [November 9, 2016, 5:23am UTC](https://discuss.elastic.co/t/how-to-get-sum-of-each-category/65230/5 "2016-11-09T05:23:03Z")

</div>

Thanks for ur reply.

if i make it to Long, is there any problem...  
Also i could see one field in the drop down as extras.responseTime ...from where it is coming, is it any in-build field.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [November 9, 2016, 6:42am UTC](https://discuss.elastic.co/t/how-to-get-sum-of-each-category/65230/6 "2016-11-09T06:42:38Z")

</div>

> if i make it to Long, is there any problem...

Long is an integer type so it'll work fine.

> Also i could see one field in the drop down as extras.responseTime ...from where it is coming, is it any in-build field.

No, that's not a built-in field.

---

<div class="post-metadata">

**Author:** ![atanu\_panda](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@atanu\_panda](https://discuss.elastic.co/u/atanu_panda)\
**Post date:** [November 9, 2016, 11:13am UTC](https://discuss.elastic.co/t/how-to-get-sum-of-each-category/65230/7 "2016-11-09T11:13:32Z")

</div>

Thanks for ur reply

---

<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:** [December 7, 2016, 11:13am UTC](https://discuss.elastic.co/t/how-to-get-sum-of-each-category/65230/8 "2016-12-07T11:13:35Z")

</div>

Closed on December 7, 2016, 11:13am UTC

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