# Visual Builder: bucket aggregation based on multiple terms

**URL:** https://discuss.elastic.co/t/visual-builder-bucket-aggregation-based-on-multiple-terms/144046
**Category:** Kibana
**Created:** [August 12, 2018, 9:12pm UTC](https://discuss.elastic.co/t/visual-builder-bucket-aggregation-based-on-multiple-terms/144046 "2018-08-12T21:12:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![albmenichetti](https://avatars.discourse-cdn.com/v4/letter/a/54ee81/32.png) [@albmenichetti](https://discuss.elastic.co/u/albmenichetti)
#### Post date: [August 12, 2018, 9:12pm UTC](https://discuss.elastic.co/t/visual-builder-bucket-aggregation-based-on-multiple-terms/144046/1 "2018-08-12T21:12:03Z")

</div>

Hi,

I need to have a bucket aggregation based on two disctinct terms; both terms are string so I could create a new field (maybe at insertion time) as concat of the two fields I need to aggregate.  
But, also for learning purposes, I think it could be done using a group by of type Filter, right? In that case, could you please show me the right query to use, supposing the fileds name are f1 and f2?

Thanks,  
Alberto

---

<div class="post-metadata">

### Author: ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)
#### Post date: [August 13, 2018, 7:55pm UTC](https://discuss.elastic.co/t/visual-builder-bucket-aggregation-based-on-multiple-terms/144046/2 "2018-08-13T19:55:05Z")

</div>

Hi Alberto,

Currently, you can't use filters in TSVB to do what you're trying to do. You can either create a new concatenated field at ingest time (as you mentioned), or you can create a [scripted field](https://www.elastic.co/guide/en/kibana/current/scripted-fields.html) to dynamically create this concatenated field.

Hope this helps,  
CJ

---

<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: [September 10, 2018, 7:55pm UTC](https://discuss.elastic.co/t/visual-builder-bucket-aggregation-based-on-multiple-terms/144046/3 "2018-09-10T19:55:08Z")

</div>

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