# Bucket sorting gives different values

**URL:** <https://discuss.elastic.co/t/bucket-sorting-gives-different-values/119228>\
**Category:** Kibana\
**Created:** [February 9, 2018, 12:05pm UTC](https://discuss.elastic.co/t/bucket-sorting-gives-different-values/119228 "2018-02-09T12:05:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert\_Naccache](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/robert_naccache/32/97656_2.png) [@Robert\_Naccache](https://discuss.elastic.co/u/Robert_Naccache)\
**Post date:** [February 9, 2018, 12:05pm UTC](https://discuss.elastic.co/t/bucket-sorting-gives-different-values/119228/1 "2018-02-09T12:05:13Z")

</div>

Hello,

Something i noticed that's a bit off and i'm not sure exactly what's the cause of it.  
My data is in the form of:

```
"businessevent": "GENERICPGPFILESOUTGOING",
"jobid": 6054972458,
"start": "2018-02-09T11:22:05.443Z",
 "difference": 1.574

```

And i'm trying to create a horizontal bar graph which has

X axis - average difference  
Y axis - buisness event

Something like this:

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

Now my issue is when sorting the bucket.  
What i want to do is sort it by greatest AVG and descending (like in the above snapshot).  
When i do it this way, hovering the mouse over the business event gives me the wrong value (in this case 2.352) and when i filter it based on the businessevent, it gives me the correct one.

I also noticed that when i sort it differently (i.e. based on term, or max value, etc) it comes out fine on both cases.

My bucket looks like this:

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

Any ideas? (sorry if the screen shots don't display, but it was the easiest way for me to describe my issue)

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Brandon\_Kobel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brandon_kobel/32/14829_2.png) [@Brandon\_Kobel](https://discuss.elastic.co/u/Brandon_Kobel)\
**Post date:** [February 12, 2018, 3:44pm UTC](https://discuss.elastic.co/t/bucket-sorting-gives-different-values/119228/2 "2018-02-12T15:44:28Z")

</div>

Hey @Robert_Naccache which version of Kibana are you running?

---

<div class="post-metadata">

**Author:** ![Robert\_Naccache](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/robert_naccache/32/97656_2.png) [@Robert\_Naccache](https://discuss.elastic.co/u/Robert_Naccache)\
**Post date:** [February 15, 2018, 7:08am UTC](https://discuss.elastic.co/t/bucket-sorting-gives-different-values/119228/3 "2018-02-15T07:08:08Z")

</div>

Hi Brandon,

Sorry i didn't notice there was a reply to this post!

I'm in the middle of updating Kibana/elasticsearch so i have the issue on both 6.1.3 and 5.6.4

Regards,  
Robert

---

<div class="post-metadata">

**Author:** ![Brandon\_Kobel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brandon_kobel/32/14829_2.png) [@Brandon\_Kobel](https://discuss.elastic.co/u/Brandon_Kobel)\
**Post date:** [February 15, 2018, 1:21pm UTC](https://discuss.elastic.co/t/bucket-sorting-gives-different-values/119228/4 "2018-02-15T13:21:52Z")

</div>

Hey @Robert_Naccache I'm having trouble recreating this issue on 6.1.3, could you mind attaching a screenshot of the full chart configuration?

---

<div class="post-metadata">

**Author:** ![Robert\_Naccache](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/robert_naccache/32/97656_2.png) [@Robert\_Naccache](https://discuss.elastic.co/u/Robert_Naccache)\
**Post date:** [February 15, 2018, 4:50pm UTC](https://discuss.elastic.co/t/bucket-sorting-gives-different-values/119228/5 "2018-02-15T16:50:08Z")

</div>

by full chart configuration, you mean this?

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

Just to kind of show you, i left the mouse over and you can see that the value is 55.979  
Once i click on the buisness event (to filter it out)

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

Value drops to 18.66 (which is the correct one, i aggregated it on elasticsearch)

Weird thing is, if i change the bucket "order by" to some other metric (i.e. by max value) it works normally.

---

<div class="post-metadata">

**Author:** ![Brandon\_Kobel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brandon_kobel/32/14829_2.png) [@Brandon\_Kobel](https://discuss.elastic.co/u/Brandon_Kobel)\
**Post date:** [February 16, 2018, 2:48pm UTC](https://discuss.elastic.co/t/bucket-sorting-gives-different-values/119228/6 "2018-02-16T14:48:14Z")

</div>

Hey @Robert_Naccache the values that we display here come from Elasticsearch and are likely a result of the following: [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation-approximate-counts](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation-approximate-counts)

---

<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:** [March 16, 2018, 2:48pm UTC](https://discuss.elastic.co/t/bucket-sorting-gives-different-values/119228/7 "2018-03-16T14:48:24Z")

</div>

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