# How can I make a calculation across multiple documents with a given ID?

**URL:** <https://discuss.elastic.co/t/how-can-i-make-a-calculation-across-multiple-documents-with-a-given-id/253475>\
**Category:** Kibana\
**Created:** [October 27, 2020, 5:32pm UTC](https://discuss.elastic.co/t/how-can-i-make-a-calculation-across-multiple-documents-with-a-given-id/253475 "2020-10-27T17:32:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alphalol](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@alphalol](https://discuss.elastic.co/u/alphalol)\
**Post date:** [October 27, 2020, 5:32pm UTC](https://discuss.elastic.co/t/how-can-i-make-a-calculation-across-multiple-documents-with-a-given-id/253475/1 "2020-10-27T17:32:57Z")

</div>

I want to be able to add a bar chart on Kibana which displays a count of users (identified by `name`) which have a total of more than 0 in `total_a` (with total of 0 for `total_b`) and column for those with a total of more than 0 in `total_b` (with total of 0 for `total_a`). So the calculation needs to take place across all documents with a given `name`.

```
[{
  "name": "foo",
  "total_a": 10,
  "total_b": 0
},
{
  "name": "foo",
  "total_a": 0,
  "total_b": 10
}, 
{
  "name": "bar",
  "total_a": 50,
  "total_b": 100
}]

```

Is this possible?

---

<div class="post-metadata">

**Author:** ![markov00](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markov00/32/33316_2.png) [@markov00](https://discuss.elastic.co/u/markov00)\
**Post date:** [November 2, 2020, 3:27pm UTC](https://discuss.elastic.co/t/how-can-i-make-a-calculation-across-multiple-documents-with-a-given-id/253475/2 "2020-11-02T15:27:48Z")

</div>

Have you tried creating a horizontal or vertical bar chart with a split series on name and a subsequent split series using a filter aggregation that filters by your clause?  
or directly a single bucket filter aggregation with name and total\_a \> 0 ?

---

<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:** [November 30, 2020, 3:27pm UTC](https://discuss.elastic.co/t/how-can-i-make-a-calculation-across-multiple-documents-with-a-given-id/253475/3 "2020-11-30T15:27:53Z")

</div>

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