# Unable to get proper sort result with 1 Subbucket

**URL:** <https://discuss.elastic.co/t/unable-to-get-proper-sort-result-with-1-subbucket/160010>\
**Category:** Kibana\
**Created:** [December 8, 2018, 12:47pm UTC](https://discuss.elastic.co/t/unable-to-get-proper-sort-result-with-1-subbucket/160010 "2018-12-08T12:47:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jmisc\_Li](https://avatars.discourse-cdn.com/v4/letter/j/e79b87/32.png) [@Jmisc\_Li](https://discuss.elastic.co/u/Jmisc_Li)\
**Post date:** [December 8, 2018, 12:47pm UTC](https://discuss.elastic.co/t/unable-to-get-proper-sort-result-with-1-subbucket/160010/1 "2018-12-08T12:47:35Z")

</div>

Hi,  
I am new to Kibana 6.5.1 and wonder if someone can help. I'm not sure if this is currently supported. I'm trying to create a line graph with data plot based on count and date with grouping of Account type.  
Y-Axis: count  
X-Axis: Terms with run\_date order by Alphabetical  
It works fine. Date is sorted properly.  
Next step, I added a sub-bucket using the account\_type field.  
Sub Aggregation: Terms  
Field: account\_type  
The X-Axis field is not sorted properly. Date field (in integer - Julian date) is no longer in ascending order.  
Is it possible to disable the sorting of the Sub Aggregation section or fix the X-Axis sorting?

I add a Date field to use an actual date (converted from Julian date) and changed the X-Axis to use Date histogram. The order seems to be good now.

Is there a way to force integer sort order as I notice there is an Advanced Setting with sort option?

Thank you

---

<div class="post-metadata">

**Author:** ![Joe\_Fleming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joe_fleming/32/3561_2.png) [@Joe\_Fleming](https://discuss.elastic.co/u/Joe_Fleming)\
**Post date:** [December 10, 2018, 8:34pm UTC](https://discuss.elastic.co/t/unable-to-get-proper-sort-result-with-1-subbucket/160010/2 "2018-12-10T20:34:41Z")

</div>

If your x-axis is using a Terms agg, it only lets you order by some metric (either one you're displaying, or a custom one) or alphabetically. Since you want to sort alphabetically, this is fine in your use case. I attempted this locally with some sample data, and it works as expected, ordering alphabetically ascending and descending.

When I add another bucket, I get the same order on the X-Axis though, but it sounds like you don't. Is it possible for you to share a screenshot or details about all of your metric and bucket configuration? Here's mine:

 ![40](https://us1.discourse-cdn.com/elastic/original/3X/f/b/fb83aff69ad0a98cee804444243311edf3d757c0.png)

I wonder if the "size" setting on the date field might be causing you issues, and maybe the results aren't what you expect them to be.

---

<div class="post-metadata">

**Author:** ![Jmisc\_Li](https://avatars.discourse-cdn.com/v4/letter/j/e79b87/32.png) [@Jmisc\_Li](https://discuss.elastic.co/u/Jmisc_Li)\
**Post date:** [December 11, 2018, 4:50pm UTC](https://discuss.elastic.co/t/unable-to-get-proper-sort-result-with-1-subbucket/160010/3 "2018-12-11T16:50:20Z")

</div>

Hi,  
Thank you for your reply. Below is the graph I have.

 ![kibana_notsorted](https://us1.discourse-cdn.com/elastic/original/3X/e/b/eb4f512ec26af6ea1e2e4bb614e733c84fe39c74.png)  
The Julian date 2018297 should be in the middle but it is not.

Y-Axis:  
Aggregation: Max  
Field : duration

If I filtered out one of the job\_id, it's sorted properly. It looks like if a sub-bucket is added, it changed the sorting result.

Thank you,  
Helen

---

<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:** [January 8, 2019, 4:50pm UTC](https://discuss.elastic.co/t/unable-to-get-proper-sort-result-with-1-subbucket/160010/4 "2019-01-08T16:50:23Z")

</div>

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