Ascending order on x-axis showing the highest bucket values


let's say I have data like this:

POST a/_bulk
{"index":{"_id" : "1"}}
{"x": 1, "y": 1}
{"index":{"_id" : "2"}}
{"x": 2, "y":2 }
{"index":{"_id" : "3"}}
{"x": 3, "y": 3}
{"index":{"_id" : "4"}}
{"x": 4, "y":4}

Now I'd like to visualize the average y for the highest three x values in ascending order. Meaning I would like to see something like in the following picture, but not for x=1,2,3 but for x=2,3,4

Is there any possibility to achieve this kind of behaviour without having to use descending order (which will show the correct x-values, but in the wrong order: x=4,3,2)

I found the following thread asking the same question:

but unfortunately as the original poster mentioned, the provided approach does not resolve the issue.

@loop welcome to the discuss forum!
I don't know what version you're running on so my screen shot is different to yours.
Running on v7.7.0, I was able to filter out the value you're not interested in using a global filter.
Steps to do this are:

  1. Create the visualization as you describe in your question above (use the same Data inputs as you have:
  • Metrics: Average aggregation on Field x
  • Buckets: X-axis Terms aggregation on field y ordered by Alphabetical Ascending, size 3.
  1. In the global filter (below the 'Save, Share, Inspect and Refresh' buttons at the top of the page), add an exclusion filter that excludes a y value of 1:
    Screen Shot 2020-05-27 at 16.12.34

You should then have your desired result:

Hi @cheiligers,
thanks for your response!
I realized that it might be not completely clear what I'm trying to achieve, so I give it one more try:

The index that I'm working with is dynamic, meaning there will be additional documents with ever-increaing x-values over time. Some x values might also be skipped.

So let's say in addtition to my example we now also have data for x=5, 6, 8, 9. In this case I would like the visualization to show me x=6,8,9, without performing manual steps on the dashboard or in the visualization itself.

A hard-coded filter to ignore certain x-values wouldn't really resolve my problem unfortunately.

Ah, yes, in that case, adding the filter won't work.
The easiest is probably to go with descending order.
Another option is to modify the axis display order. You can do that using a different visualization type: TSVB.
The flights example dataset has a TSVB visualization that you could take a look at as an example. TSVB is very powerful but has a steep learning curve. There's a webinar that walks one through the basics of TSVB. You can also look through this forum for more questions on using that visualization.
Good luck and happy learning!

1 Like

Hi @cheiligers,

thank you very much for your reply. I couldn't really find an option on how to do this in TSVB, as it requires a time field for the x-axis as far as I see. I was not able to select non-date fields. So I guess I need to stick to using the descending order.

But besides this I found the Markdown feature in TSVB really helpful. So thanks a lot for leading me into this direction!

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