Can't order by metric: MaxBucket in visualisation

Hey,
I'm trying to make a (preferably bar) visualisation using the Max Bucket metric. The reason I'm using Max Bucket is because datapoints repeat per weekly basis spread over a year and I'm only looking for week with the maximum size. These metrics should again be bucketed between cities, however I can't order by the Max Bucket metric as it is greyed out, seen in the added image. Additionally order by Custom metric does not work as it doesn't include the max bucket metric. Why is it greyed out? And is there any workaround?

Versions
Using kibana 6.2.4 and ES 6.2.4

Hello,

This is a limitation that comes from Elasticseach, where pipeline aggregation cannot be used for ordering as they are run during the reduce phase of the query.
You can read a bit more about it over here: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation-order

Hey,
Thanks a lot for the help. I managed to find a workaround using the Visual Builder if anyone else has this problem:
In the Visual Builder choose the Top N option.
In the Panel Options make sure to choose the correct timestamp and Interval time aggregation (daily, weekly etc.)
In the first metric choose Sum of your X (or any other aggregation)
In the second metric choose Overall Max of your first metric
Finally group by the term you want to model.

These steps will give you a correctly ordered bar chart.

1 Like

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