# How to aggregation by tree(Bar Chart)

**URL:** <https://discuss.elastic.co/t/how-to-aggregation-by-tree-bar-chart/284531>\
**Category:** Kibana\
**Created:** [September 18, 2021, 6:28am UTC](https://discuss.elastic.co/t/how-to-aggregation-by-tree-bar-chart/284531 "2021-09-18T06:28:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ruif0](https://avatars.discourse-cdn.com/v4/letter/r/ee7513/32.png) [@ruif0](https://discuss.elastic.co/u/ruif0)\
**Post date:** [September 18, 2021, 6:28am UTC](https://discuss.elastic.co/t/how-to-aggregation-by-tree-bar-chart/284531/1 "2021-09-18T06:28:13Z")

</div>

My data look like this:

```auto
{
	"type":"Error",
	"server":["Country1/State1/City1",null]
}

{
	"type":"Error",
	"server":["Country1/State2/City2",null]
}

{
	"type":"Error",
	"server":["Country2/State3/City3",null]
}

```

I want to create a bar chart which count by country first, when user click one of the country bar, the chart refresh and show the count by state.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/f/3f0be2254035aeafff0d6636e4047d95bdbf576c.png)

Can I do this with Kibana?

---

<div class="post-metadata">

**Author:** ![tmp13](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tmp13/32/78005_2.png) [@tmp13](https://discuss.elastic.co/u/tmp13)\
**Post date:** [September 19, 2021, 7:30pm UTC](https://discuss.elastic.co/t/how-to-aggregation-by-tree-bar-chart/284531/2 "2021-09-19T19:30:06Z")

</div>

Hi.  
_"when user click one of the country bar, the chart refresh and show the count by state"_ I think that is impossible, but you can try drilldown:

> [Make dashboards interactive | Kibana Guide [8.11] | Elastic](https://www.elastic.co/guide/en/kibana/current/drilldowns.html)

You can create two dashboards:

1. First contains "All Country" like this  

2. Second contains "All State" like this:  

(You can add more dashboards: city, street etc...)

On first (All Country) you can add drilldown (see first screen), by click on that you will go to second dashboard with filter by country:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1a625003c6423273cb8ef6acf740fd851c092d54.png)

And on dashboard "All State" you will see:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/4/244cb7564f056dde92516f12d6d2d9b9bdd08d64.png)

But I don`t understand your data... I created simple index like this:  
_GET cstate/\_source/1_  
{  
"server" : "1",  
"country" : "US",  
"state" : "Alaska"  
}

etc...  
I hope it will help...

---

<div class="post-metadata">

**Author:** ![ruif0](https://avatars.discourse-cdn.com/v4/letter/r/ee7513/32.png) [@ruif0](https://discuss.elastic.co/u/ruif0)\
**Post date:** [September 22, 2021, 1:06am UTC](https://discuss.elastic.co/t/how-to-aggregation-by-tree-bar-chart/284531/3 "2021-09-22T01:06:24Z")

</div>

Thanks! But my client want to do this with one chart. 😂

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 22, 2021, 4:58am UTC](https://discuss.elastic.co/t/how-to-aggregation-by-tree-bar-chart/284531/4 "2021-09-22T04:58:44Z")

</div>

The drilldown approach above is currently the only way to do this in Kibana.

---

<div class="post-metadata">

**Author:** ![tmp13](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tmp13/32/78005_2.png) [@tmp13](https://discuss.elastic.co/u/tmp13)\
**Post date:** [September 22, 2021, 7:18am UTC](https://discuss.elastic.co/t/how-to-aggregation-by-tree-bar-chart/284531/5 "2021-09-22T07:18:45Z")

</div>

Create two maximum similar dashboards and  
your client won't see the difference between drilldown and refresh (may be only filter in up corner) 🤣

---

<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:** [October 20, 2021, 7:19am UTC](https://discuss.elastic.co/t/how-to-aggregation-by-tree-bar-chart/284531/6 "2021-10-20T07:19:01Z")

</div>

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