# On x Axis show biggest 20 Values, but in Ascending Order

**URL:** <https://discuss.elastic.co/t/on-x-axis-show-biggest-20-values-but-in-ascending-order/258616>\
**Category:** Kibana\
**Created:** [December 14, 2020, 4:58pm UTC](https://discuss.elastic.co/t/on-x-axis-show-biggest-20-values-but-in-ascending-order/258616 "2020-12-14T16:58:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![grra](https://avatars.discourse-cdn.com/v4/letter/g/a6a055/32.png) [@grra](https://discuss.elastic.co/u/grra)\
**Post date:** [December 14, 2020, 4:58pm UTC](https://discuss.elastic.co/t/on-x-axis-show-biggest-20-values-but-in-ascending-order/258616/1 "2020-12-14T16:58:33Z")

</div>

Hi, I want to visualize the RAM usage of some builds.

As fields I have:

```auto
"metrics": { "ram": ram_value } // on the y - Axis, and
"buildnumber": num // on the x - Axis.

```

The maximum y - Value is the highest ram value, and on the x - Axis I am showing the last 20. Buildnumbers descending, right now.

What I actually want:  
Show the last 20 Builds - But in an ascending order.

So I want to query the 20 highest values of Build-numbers. And after that I want to show those on the x - Axis.

Is that possible?

Sorry if I miss important information, I am a total Kibana beginner.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [December 15, 2020, 12:54am UTC](https://discuss.elastic.co/t/on-x-axis-show-biggest-20-values-but-in-ascending-order/258616/2 "2020-12-15T00:54:07Z")

</div>

Welcome to our community! 😃

It should be possible yes. If you've tried to do this and you haven't gotten it working, posting some screenshots of your settings would help us direct you to a solution.

---

<div class="post-metadata">

**Author:** ![grra](https://avatars.discourse-cdn.com/v4/letter/g/a6a055/32.png) [@grra](https://discuss.elastic.co/u/grra)\
**Post date:** [December 15, 2020, 7:34am UTC](https://discuss.elastic.co/t/on-x-axis-show-biggest-20-values-but-in-ascending-order/258616/3 "2020-12-15T07:34:55Z")

</div>

Hi. 🙂  
In the `Discover` tab I have an index `vd_memory_usage` which contains fields like that:

 ![Screenshot 2020-12-15 at 08.03.16](https://us1.discourse-cdn.com/elastic/original/3X/d/5/d5de19e80d5fadd3a5f3128a092dbdf6d2e9bf36.png)

Every several hours I get new Build Number values in ascending order.

On the `Visualize` tab I have settings like that:

 ![Screenshot 2020-12-15 at 08.16.30](https://us1.discourse-cdn.com/elastic/original/3X/c/a/caa8c3bcb0aeb7c90c711d552d0121a000ce694a.png)

On the dashboard I want to show the last 20 Build-Numbers, but in ascending order from left..  
Right now, if I set Buckets\<X-Axis\<Order\<Ascending of course I miss many builds because in the Database they start at Buildnumber 600.

I tried to query in different ways on the `Dev-Tools` tab, but nothing worked fine for me.

It would be nice, if someone has an idea how to do that.

---

<div class="post-metadata">

**Author:** ![grra](https://avatars.discourse-cdn.com/v4/letter/g/a6a055/32.png) [@grra](https://discuss.elastic.co/u/grra)\
**Post date:** [December 15, 2020, 1:33pm UTC](https://discuss.elastic.co/t/on-x-axis-show-biggest-20-values-but-in-ascending-order/258616/4 "2020-12-15T13:33:00Z")

</div>

Is they only way to achieve that, using Scripted Fields, or is that even possible with those?

Because, with that query in `Dev-Tools` tab, I get the last 20 build numbers. (But still in descending order..)

```auto
GET /memory_usage/_search
{
  "query": {
    "match": {
      "test_env.build_job_name": "MyBuildJobName"
    }
  },
  "aggs": {
    "distinct_number": {
      "cardinality": {
        "field": "test_env.build_number"
      }
    },
    "test_env.build_number": {
      "top_hits": {
        "sort": [
          {
            "test_env.build_number": {
              "order": "desc"
            }
          }
        ],
        "size": 20
      }
    }
  }
}

```

Thanks in advance.

---

<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 12, 2021, 1:33pm UTC](https://discuss.elastic.co/t/on-x-axis-show-biggest-20-values-but-in-ascending-order/258616/5 "2021-01-12T13:33:07Z")

</div>

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