# Incorrect Order by Descending in Kibana visualization

**URL:** https://discuss.elastic.co/t/incorrect-order-by-descending-in-kibana-visualization/48984
**Category:** Kibana
**Created:** [May 2, 2016, 5:23pm UTC](https://discuss.elastic.co/t/incorrect-order-by-descending-in-kibana-visualization/48984 "2016-05-02T17:23:22Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![anhlqn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anhlqn/32/5454_2.png) [@anhlqn](https://discuss.elastic.co/u/anhlqn)
#### Post date: [May 2, 2016, 5:23pm UTC](https://discuss.elastic.co/t/incorrect-order-by-descending-in-kibana-visualization/48984/1 "2016-05-02T17:23:22Z")

</div>

I have created a visualization to show the number of netflows per IPV4\_SRC\_ADDR over time. It is supposed to sort the IP in the legend by Count in descending order. However as you look at the graph below, the IP with pink column occupies most of the flows, but it is at the 13th of the legend while all other IPs with very low flows sit on the top of the legend.

 ![](https://us1.discourse-cdn.com/elastic/original/2X/f/f9235963a6db0e329171274d2961a50eae39c502.jpg)

My first thought is that Kibana sorting bases on values in the last column or the overall values in the visualization, but it does not seem to be true.

I've been having issues with those types of graphs where Date Histogram is combined with Bars or Lines, and I am not sure how Kibana actually sorts values.

---

<div class="post-metadata">

### Author: ![Bargs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bargs/32/5429_2.png) [@Bargs](https://discuss.elastic.co/u/Bargs)
#### Post date: [May 2, 2016, 11:01pm UTC](https://discuss.elastic.co/t/incorrect-order-by-descending-in-kibana-visualization/48984/2 "2016-05-02T23:01:23Z")

</div>

Hi @anhlqn, as far as I know the `Order By` setting is not intended to affect the Kibana UI. It only affects the Elasticsearch aggregation, specifically it maps directly to the [Order setting](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation-order) in the terms agg.

---

<div class="post-metadata">

### Author: ![anhlqn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anhlqn/32/5454_2.png) [@anhlqn](https://discuss.elastic.co/u/anhlqn)
#### Post date: [May 5, 2016, 2:00am UTC](https://discuss.elastic.co/t/incorrect-order-by-descending-in-kibana-visualization/48984/3 "2016-05-05T02:00:58Z")

</div>

Thanks, is there any plan/way to make it effective in Kibana UI too? It's pretty confusing to see the graph like that.

---

<div class="post-metadata">

### Author: ![Bargs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bargs/32/5429_2.png) [@Bargs](https://discuss.elastic.co/u/Bargs)
#### Post date: [May 5, 2016, 2:46pm UTC](https://discuss.elastic.co/t/incorrect-order-by-descending-in-kibana-visualization/48984/4 "2016-05-05T14:46:33Z")

</div>

It looks like it's still an open discussion on this ticket [https://github.com/elastic/kibana/issues/3118](https://github.com/elastic/kibana/issues/3118)

Your input would definitely be appreciated on the ticket.

---

<div class="post-metadata">

### Author: ![anhlqn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anhlqn/32/5454_2.png) [@anhlqn](https://discuss.elastic.co/u/anhlqn)
#### Post date: [May 5, 2016, 3:39pm UTC](https://discuss.elastic.co/t/incorrect-order-by-descending-in-kibana-visualization/48984/5 "2016-05-05T15:39:18Z")

</div>

I've posted on the ticket. You said that Order By is not intended to affect Kibana UI, but why does this issue only occur when I use Date Histogram + Split bars? Order By works fine for a simple pie chart or bar chart.

---

<div class="post-metadata">

### Author: ![Bargs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bargs/32/5429_2.png) [@Bargs](https://discuss.elastic.co/u/Bargs)
#### Post date: [May 5, 2016, 4:09pm UTC](https://discuss.elastic.co/t/incorrect-order-by-descending-in-kibana-visualization/48984/6 "2016-05-05T16:09:47Z")

</div>

Unfortunately I'm not terribly familiar with the vislib code, I'd have to dig in to see what's going on exactly. I know @Khalah_Jones_Golden is a bit more familiar with it, he might be able to say whether this is an actual bug or not.

---

<div class="post-metadata">

### Author: ![spalger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spalger/32/14092_2.png) [@spalger](https://discuss.elastic.co/u/spalger)
#### Post date: [May 5, 2016, 11:13pm UTC](https://discuss.elastic.co/t/incorrect-order-by-descending-in-kibana-visualization/48984/7 "2016-05-05T23:13:42Z")

</div>

As you pointed out the ordering is only off when you combine the date histogram and the split bars. This is because the legend shows values in the order that they appear from left to right, meaning that all of the IP's from the small bars on the left of that chart are going to be at the top of the legend, followed by the IP addresses in the second day, and so on.

The reality is simply that both the date histogram and the terms agg have an order (even though the order of time is implicit) and the display of values in the legend reflects the order defined by the nested aggregations.

To get the view that you are looking for I suggest you try a data table, which allows you to sort by arbitrary columns. You could use place this next to your histogram on a dashboard and use them together to drill down and get the experience you are looking for. Hope that helps!

---

<div class="post-metadata">

### Author: ![anhlqn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anhlqn/32/5454_2.png) [@anhlqn](https://discuss.elastic.co/u/anhlqn)
#### Post date: [May 6, 2016, 3:47am UTC](https://discuss.elastic.co/t/incorrect-order-by-descending-in-kibana-visualization/48984/8 "2016-05-06T03:47:23Z")

</div>

Thanks, I'll try

---

<div class="post-metadata">

### Author: ![exorcista](https://avatars.discourse-cdn.com/v4/letter/e/e5b9ba/32.png) [@exorcista](https://discuss.elastic.co/u/exorcista)
#### Post date: [May 20, 2016, 3:26pm UTC](https://discuss.elastic.co/t/incorrect-order-by-descending-in-kibana-visualization/48984/9 "2016-05-20T15:26:04Z")

</div>

Hi all.  
I am facing the same issue, it is correct that order is working with the pie chart but it is not for histogram..

---

<div class="post-metadata">

### Author: ![seth.yes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/seth.yes/32/11788_2.png) [@seth.yes](https://discuss.elastic.co/u/seth.yes)
#### Post date: [July 18, 2016, 9:41pm UTC](https://discuss.elastic.co/t/incorrect-order-by-descending-in-kibana-visualization/48984/10 "2016-07-18T21:41:08Z")

</div>

I'm seeing the same issue -- latest supported version of E, L & K - however in a bar graph, even without split bars, a split chart will not order by terms, nor by any metric, seems almost randomly placed - creating a new visualization does not resolve the issue.

---

<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: [July 6, 2017, 1:45pm UTC](https://discuss.elastic.co/t/incorrect-order-by-descending-in-kibana-visualization/48984/11 "2017-07-06T13:45:55Z")

</div>


