# How to select the top groups based on the relative occurence of a value in another variable

**URL:** <https://discuss.elastic.co/t/how-to-select-the-top-groups-based-on-the-relative-occurence-of-a-value-in-another-variable/223087>\
**Category:** Kibana\
**Created:** [March 11, 2020, 9:47am UTC](https://discuss.elastic.co/t/how-to-select-the-top-groups-based-on-the-relative-occurence-of-a-value-in-another-variable/223087 "2020-03-11T09:47:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amon](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@Amon](https://discuss.elastic.co/u/Amon)\
**Post date:** [March 11, 2020, 9:47am UTC](https://discuss.elastic.co/t/how-to-select-the-top-groups-based-on-the-relative-occurence-of-a-value-in-another-variable/223087/1 "2020-03-11T09:47:55Z")

</div>

Dear,

Two variables in my dataset are important for this question namely : "Country\_code" and "Tunnel\_status". See example

Country\_Code Tunnel\_status  
BE Up  
NL Up  
FR Down

BE Up  
NL Up  
FR Down

BE Up  
NL Down  
FR Up

What I wanted do to now is the following : the availability in BE was 100%, the one in NL was 66% and the one in FR was 33%. I want to filter on the countries with an availability lower then 33% so keep only France. The way how it is visualised is not so important for me, it should just be easy to see and to filter on the country codes with an availability lower then 33%.

Thanks in advance!

Kind regards,  
Amon

---

<div class="post-metadata">

**Author:** ![lukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas/32/6812_2.png) [@lukas](https://discuss.elastic.co/u/lukas)\
**Post date:** [March 11, 2020, 5:17pm UTC](https://discuss.elastic.co/t/how-to-select-the-top-groups-based-on-the-relative-occurence-of-a-value-in-another-variable/223087/2 "2020-03-11T17:17:26Z")

</div>

Unfortunately I don't think you can accomplish exactly what you want here until Kibana supports bucket selectors: [https://github.com/elastic/kibana/issues/11167](https://github.com/elastic/kibana/issues/11167)

Alternatively, you could visualize this data and sort by availability ascending, but you would still see all of the data (even that above 33%) in the visualization.

---

<div class="post-metadata">

**Author:** ![Amon](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@Amon](https://discuss.elastic.co/u/Amon)\
**Post date:** [March 23, 2020, 12:35pm UTC](https://discuss.elastic.co/t/how-to-select-the-top-groups-based-on-the-relative-occurence-of-a-value-in-another-variable/223087/3 "2020-03-23T12:35:58Z")

</div>

Dear Lukas,

First of all thank you for your answer, currently I'm doing this task in a Heatmap.

Metrics

- Y-Axis  
Aggregation : count

- Buckets

-Split series  
Sub aggregation  
Field : Tunnel\_Status

And then I have selected in Metrics and aces -\> Y)aces -\> mode percentages. This gives me a nice view but if I click on order by then it orders based on the count of occurences in a country and not on the percentage.

Kind regards,  
Amon

---

<div class="post-metadata">

**Author:** ![Amon](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@Amon](https://discuss.elastic.co/u/Amon)\
**Post date:** [March 23, 2020, 3:27pm UTC](https://discuss.elastic.co/t/how-to-select-the-top-groups-based-on-the-relative-occurence-of-a-value-in-another-variable/223087/4 "2020-03-23T15:27:19Z")

</div>

Hey Lukas,

Maybe an important detail to add is that I have over 100 country codes.

Kind regards,  
Amon

---

<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 20, 2020, 3:27pm UTC](https://discuss.elastic.co/t/how-to-select-the-top-groups-based-on-the-relative-occurence-of-a-value-in-another-variable/223087/5 "2020-04-20T15:27:32Z")

</div>

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