# Group input values in Bar Chart Aggregation

**URL:** https://discuss.elastic.co/t/group-input-values-in-bar-chart-aggregation/327306
**Category:** Kibana
**Tags:** visualisation
**Created:** [March 8, 2023, 8:28pm UTC](https://discuss.elastic.co/t/group-input-values-in-bar-chart-aggregation/327306 "2023-03-08T20:28:57Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Miriam99](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/miriam99/32/118223_2.png) [@Miriam99](https://discuss.elastic.co/u/Miriam99)
#### Post date: [March 8, 2023, 8:28pm UTC](https://discuss.elastic.co/t/group-input-values-in-bar-chart-aggregation/327306/1 "2023-03-08T20:28:57Z")

</div>

If I have documents where value.keyword = A1, value.keyword = A2 ... A3, B1, B2, B3  
How would I get all of the A values to group together and B values to group together instead of having 6 separate bars on my graph?

This is using Visualization - Aggregation, not lens  
Thanks

---

<div class="post-metadata">

### Author: ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)
#### Post date: [March 9, 2023, 2:22pm UTC](https://discuss.elastic.co/t/group-input-values-in-bar-chart-aggregation/327306/2 "2023-03-09T14:22:37Z")

</div>

Hi Miriam. The best way to do this is by adding a new "group" field and populate this field at ingest. So your documents might look like `{ "value": "A1", "group": "A" }`. Then you could perform the aggregation on the `group` field. But you'll need to update your existing documents using [`reindex` with a `pipeline`](https://www.elastic.co/guide/en/elasticsearch/reference/8.6/docs-reindex.html#reindex-with-an-ingest-pipeline) to populate the `group` field.

A second-best way to do this, but maybe less performant, is to create a `group` [runtime field](https://www.elastic.co/guide/en/elasticsearch/reference/current/runtime.html). This involves a little scripting, but you don't need to update your existing documents.

---

<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: [April 6, 2023, 2:23pm UTC](https://discuss.elastic.co/t/group-input-values-in-bar-chart-aggregation/327306/3 "2023-04-06T14:23:35Z")

</div>

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