# How to filter visualization based on result of aggregate?

**URL:** <https://discuss.elastic.co/t/how-to-filter-visualization-based-on-result-of-aggregate/126669>\
**Category:** Kibana\
**Created:** [April 4, 2018, 4:30am UTC](https://discuss.elastic.co/t/how-to-filter-visualization-based-on-result-of-aggregate/126669 "2018-04-04T04:30:28Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![thomasneirynck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomasneirynck/32/23313_2.png) [@thomasneirynck](https://discuss.elastic.co/u/thomasneirynck)\
**Post date:** [April 4, 2018, 6:10pm UTC](https://discuss.elastic.co/t/how-to-filter-visualization-based-on-result-of-aggregate/126669/3 "2018-04-04T18:10:40Z")

</div>

hi @Steven_Ensslen,

this is similar to a HAVING clause in SQL.

Elasticsearch has something called a "bucket selector": [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-selector-aggregation.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-selector-aggregation.html). This is likely what you'd want to use.

This functionality is not available in Kibana though. There's an open ER for that: [https://github.com/elastic/kibana/issues/11167](https://github.com/elastic/kibana/issues/11167).

If you think that's in-line with what you need, I would go and upvote that ticket.

If you are willing to get down and dirty, you may be able to work around this limitation by creating a Vega-visualization. Vega is a declarative languages for visualizations, and it can handle rudimentary tables (e.g. [https://vega.github.io/vega-lite/docs/text.html#text-table-heatmap](https://vega.github.io/vega-lite/docs/text.html#text-table-heatmap)). Kibana has a plugin in 6.2, and it allows you to put in the raw ES-query for your data ([https://www.elastic.co/guide/en/kibana/current/vega-graph.html](https://www.elastic.co/guide/en/kibana/current/vega-graph.html)). This is an experimental feature in Kibana, but may be worth checking out.

---

_[View the full topic](https://discuss.elastic.co/t/how-to-filter-visualization-based-on-result-of-aggregate/126669)._
