# Top N Visual Builder Count Not Working

**URL:** https://discuss.elastic.co/t/top-n-visual-builder-count-not-working/122357
**Category:** Kibana
**Created:** [March 3, 2018, 7:33am UTC](https://discuss.elastic.co/t/top-n-visual-builder-count-not-working/122357 "2018-03-03T07:33:09Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![wwalker](https://avatars.discourse-cdn.com/v4/letter/w/43a26b/32.png) [@wwalker](https://discuss.elastic.co/u/wwalker)
#### Post date: [March 3, 2018, 7:33am UTC](https://discuss.elastic.co/t/top-n-visual-builder-count-not-working/122357/1 "2018-03-03T07:33:09Z")

</div>

I've had various issues with the Top N displaying properly for the Visual Builder. On versions previous to 6.2.2, it would count the total instances but not always sort them in descending order. Currently, this is what I have going on:

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

The term being grouped is geoip.country\_name.keyword. As you can see, it's showing zero across the board but if I build it via a table, as shown below, there are definitely values that can be counted. What am I doing wrong here?

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

---

<div class="post-metadata">

### Author: ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)
#### Post date: [March 4, 2018, 12:33am UTC](https://discuss.elastic.co/t/top-n-visual-builder-count-not-working/122357/2 "2018-03-04T00:33:25Z")

</div>

The way that Time Series Visual Builder works is different than a Data Table Visualization, because in TSVB, everything starts with a histogram that uses a time interval from a timestamp field.

It's easier to understand if you start from the "Time Series" chart. I made a chart with server logs and put it into a chart.

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

My mouse cursor is all the way to the left, and the legend is showing top terms for that last time bucket.

Without changing any of the panel options, I change to "Top N"

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/5/0/5095a3c8caff9f13e8a2a2260abfaf29dcaef81e.png)

The terms here are just a "blown up" view of the terms shown in the last time bucket of the Time Series chart.

If you're getting only zeroes for the Top N chart, take a look at what the data looks like in the Time Series view. The time range could be expanded in a way that makes the last time bucket have zero counts for terms that exist in earlier time buckets.

---

<div class="post-metadata">

### Author: ![wwalker](https://avatars.discourse-cdn.com/v4/letter/w/43a26b/32.png) [@wwalker](https://discuss.elastic.co/u/wwalker)
#### Post date: [March 4, 2018, 1:13am UTC](https://discuss.elastic.co/t/top-n-visual-builder-count-not-working/122357/3 "2018-03-04T01:13:40Z")

</div>

Doing as you said, here's what it looks like:

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

If I then switch to Top N, I get all zeros. If I refine the time frame to a small slice that has no zeros, then I get values in Top N. So I guess what I am trying to accomplish is a Top 10 of countries that appear in a given time. I like the vertical bar graph the TSVB provides, does one of the other visualizations more appropriately fit my needs/desires?

---

<div class="post-metadata">

### Author: ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)
#### Post date: [March 4, 2018, 1:17am UTC](https://discuss.elastic.co/t/top-n-visual-builder-count-not-working/122357/4 "2018-03-04T01:17:09Z")

</div>

Yes, you can choose "Horizontal Bar Chart" when choosing your type of new visualization:

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

---

<div class="post-metadata">

### Author: ![wwalker](https://avatars.discourse-cdn.com/v4/letter/w/43a26b/32.png) [@wwalker](https://discuss.elastic.co/u/wwalker)
#### Post date: [March 4, 2018, 1:18am UTC](https://discuss.elastic.co/t/top-n-visual-builder-count-not-working/122357/5 "2018-03-04T01:18:04Z")

</div>

Ya, I asked the question before going and looking for myself, lol. I am currently playing with it, thanks for the help @tsullivan

---

<div class="post-metadata">

### Author: ![wwalker](https://avatars.discourse-cdn.com/v4/letter/w/43a26b/32.png) [@wwalker](https://discuss.elastic.co/u/wwalker)
#### Post date: [March 4, 2018, 1:40am UTC](https://discuss.elastic.co/t/top-n-visual-builder-count-not-working/122357/6 "2018-03-04T01:40:10Z")

</div>

OK, one more question. With the TSVB, I could link the each Top N entry. I don't see the ability to do that with the Horizontal Bar visualization. Is there a way or different visualization that will give me that functionality as well?

---

<div class="post-metadata">

### Author: ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)
#### Post date: [March 4, 2018, 2:02am UTC](https://discuss.elastic.co/t/top-n-visual-builder-count-not-working/122357/7 "2018-03-04T02:02:51Z")

</div>

Sorry, that does not work for the "core" visualization types when the value to format is in the legend of a chart.

You can add a field formatter to an index pattern to have Kibana format the field how you want whenever it is displayed, but when it gets formatted in a legend, there is no clickable link:

The best I could get is something that looks like this:

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

---

<div class="post-metadata">

### Author: ![wwalker](https://avatars.discourse-cdn.com/v4/letter/w/43a26b/32.png) [@wwalker](https://discuss.elastic.co/u/wwalker)
#### Post date: [March 4, 2018, 2:15am UTC](https://discuss.elastic.co/t/top-n-visual-builder-count-not-working/122357/8 "2018-03-04T02:15:44Z")

</div>

Sounds good, thanks again @tsullivan.

---

<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 1, 2018, 2:15am UTC](https://discuss.elastic.co/t/top-n-visual-builder-count-not-working/122357/9 "2018-04-01T02:15:46Z")

</div>

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