# Can I add a sub "term" "aggregation" for a x-axis filters aggregation?

**URL:** https://discuss.elastic.co/t/can-i-add-a-sub-term-aggregation-for-a-x-axis-filters-aggregation/294533
**Category:** Kibana
**Created:** [January 17, 2022, 6:23am UTC](https://discuss.elastic.co/t/can-i-add-a-sub-term-aggregation-for-a-x-axis-filters-aggregation/294533 "2022-01-17T06:23:21Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![rogerlee](https://avatars.discourse-cdn.com/v4/letter/r/258eb7/32.png) [@rogerlee](https://discuss.elastic.co/u/rogerlee)
#### Post date: [January 17, 2022, 6:23am UTC](https://discuss.elastic.co/t/can-i-add-a-sub-term-aggregation-for-a-x-axis-filters-aggregation/294533/1 "2022-01-17T06:23:21Z")

</div>

Hello, experts. I am trying to customize an aggregation via "Json Input" for a horizontal bar chart, and the data I am using is the flight demo data. The purpose is that I want to specify aggregations for every filter on x-axis.

I inputed the script like:

```auto
{
    "aggs": {
                        "3": {
                            "terms": {
                                "field": "DestCityName",
                                "order": {
                                    "_count": "desc"
                                },
                                "size": 5
                            }
                        }
                    }
    
}

```

But the system indicates me "search error". Is there any suggestion?

 ![截屏2022-01-17 下午2.18.47](https://us1.discourse-cdn.com/elastic/original/3X/5/6/56eb7131deca60e268894a1ce54992d7a799e823.png)

---

<div class="post-metadata">

### Author: ![Tomo\_M](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@Tomo\_M](https://discuss.elastic.co/u/Tomo_M)
#### Post date: [January 17, 2022, 7:48am UTC](https://discuss.elastic.co/t/can-i-add-a-sub-term-aggregation-for-a-x-axis-filters-aggregation/294533/2 "2022-01-17T07:48:49Z")

</div>

Hello,

"Split sereis" is not enough for you?  
Is there any reason to use Json input for sub-aggregation?

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

---

<div class="post-metadata">

### Author: ![rogerlee](https://avatars.discourse-cdn.com/v4/letter/r/258eb7/32.png) [@rogerlee](https://discuss.elastic.co/u/rogerlee)
#### Post date: [January 17, 2022, 7:54am UTC](https://discuss.elastic.co/t/can-i-add-a-sub-term-aggregation-for-a-x-axis-filters-aggregation/294533/3 "2022-01-17T07:54:18Z")

</div>

Thank you for your reply. I found that the sub aggregation applied to all filters. I want to use sub-aggregation for specific filter.

---

<div class="post-metadata">

### Author: ![Tomo\_M](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@Tomo\_M](https://discuss.elastic.co/u/Tomo_M)
#### Post date: [January 17, 2022, 2:06pm UTC](https://discuss.elastic.co/t/can-i-add-a-sub-term-aggregation-for-a-x-axis-filters-aggregation/294533/4 "2022-01-17T14:06:52Z")

</div>

I suppose it's difficult. Why not making multiple charts?

---

<div class="post-metadata">

### Author: ![rogerlee](https://avatars.discourse-cdn.com/v4/letter/r/258eb7/32.png) [@rogerlee](https://discuss.elastic.co/u/rogerlee)
#### Post date: [January 18, 2022, 4:50am UTC](https://discuss.elastic.co/t/can-i-add-a-sub-term-aggregation-for-a-x-axis-filters-aggregation/294533/5 "2022-01-18T04:50:19Z")

</div>

Hi Tomo. Multiple charts is difficult for my use case to be understand by user. I am thinking the solution about Vega. Do you have some advice?

---

<div class="post-metadata">

### Author: ![Tomo\_M](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@Tomo\_M](https://discuss.elastic.co/u/Tomo_M)
#### Post date: [January 18, 2022, 5:50am UTC](https://discuss.elastic.co/t/can-i-add-a-sub-term-aggregation-for-a-x-axis-filters-aggregation/294533/6 "2022-01-18T05:50:18Z")

</div>

Vega-lite has high flexibility worth trying.

---

<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: [February 15, 2022, 5:50am UTC](https://discuss.elastic.co/t/can-i-add-a-sub-term-aggregation-for-a-x-axis-filters-aggregation/294533/7 "2022-02-15T05:50:51Z")

</div>

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