# Help with query aggregation for data table

**URL:** <https://discuss.elastic.co/t/help-with-query-aggregation-for-data-table/209298>\
**Category:** Elasticsearch\
**Created:** [November 25, 2019, 12:14pm UTC](https://discuss.elastic.co/t/help-with-query-aggregation-for-data-table/209298 "2019-11-25T12:14:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bruce289](https://avatars.discourse-cdn.com/v4/letter/b/7bcc69/32.png) [@bruce289](https://discuss.elastic.co/u/bruce289)\
**Post date:** [November 25, 2019, 12:14pm UTC](https://discuss.elastic.co/t/help-with-query-aggregation-for-data-table/209298/1 "2019-11-25T12:14:37Z")

</div>

Hi,

Following are 3 example documents containing the total memory on a host and the hypervisor it is hosted on. I would like to create a table visualisation that shows the amount of unassigned memory on each hypervisor, but I haven't been able to figure out how to do it

Documents:

```auto
{
  "host" : {
    "name : "guest-1"
  },
  "memory" : {
    "total" : 16
  },
  "hypervisor" : "hypervisor-1"
}

```

```auto
{
  "host" : {
    "name : "guest-2"
  },
  "memory" : {
    "total" : 32
  },
  "hypervisor" : "hypervisor-1"
}

```

```auto
{
  "host" : {
    "name : "hypervisor-1"
  },
  "memory" : {
    "total" : 64
  }
}

```

Required data table output given the documents above:

```auto
Hypervisor | Unassigned memory
--------------+------------------
hypervisor-1 | 16

```

It would be great if someone could point me in the right direction here. I'm able to get the total memory used by guests by grouping by hypervisor, but I don't know how to then subtract that from the total memory on the hypervisor. Or maybe that's the wrong way to go about it. Any ideas would be much appreciated.

Thanks.

---

<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 23, 2019, 12:14pm UTC](https://discuss.elastic.co/t/help-with-query-aggregation-for-data-table/209298/2 "2019-12-23T12:14:39Z")

</div>

Closed on December 23, 2019, 12:14pm UTC

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