View time series for top X keywords

I have some time series data with revenue metrics and country codes on it.
I want to plot a time series linechart with revenue per day, for top 5 countries.

To do this, I create a visualization with sum revenue on Y axis, and then create buckets for X-axis with Date Histogram. Then I create sub-bucket aggregation based on country.keyword.

But I do not get top 5 countries for the whole period. I get top 5 countries for each day, and more than 5 countries end up on my chart:

How do I split my series not by top 5 countries with highest revenue for each day, but by top 5 countries with highest revenue for the whole time period selected?

You can sort your bucket aggregations by dragging the little handle next to the "X". If you move the split series aggregation to the top, it will get applied first and will use the top 5 countries for the whole time period.

It's also described in the docs https://www.elastic.co/guide/en/kibana/current/most-frequent.html (around halfway through)

The new aggregation is added after the first one, so the result shows the top 5 sources of traffic per 3 hours. If you want to change the aggregation order, you can do so by dragging:

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