# Show number as percentile in elasticsearch DSL

**URL:** <https://discuss.elastic.co/t/show-number-as-percentile-in-elasticsearch-dsl/314506>\
**Category:** Elasticsearch\
**Created:** [September 15, 2022, 12:02pm UTC](https://discuss.elastic.co/t/show-number-as-percentile-in-elasticsearch-dsl/314506 "2022-09-15T12:02:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aniket\_Pant](https://avatars.discourse-cdn.com/v4/letter/a/77aa72/32.png) [@Aniket\_Pant](https://discuss.elastic.co/u/Aniket_Pant)\
**Post date:** [September 15, 2022, 12:02pm UTC](https://discuss.elastic.co/t/show-number-as-percentile-in-elasticsearch-dsl/314506/1 "2022-09-15T12:02:13Z")

</div>

Sample data

```auto
Name response_code  
abc 6780
abc2 9999
abc3 1000
abc4 3456
.
.
.
abc20 9700

```

I want two perform following task

1. Show those response\_code whoes value is greater than 3000
2. Show response\_code as percentile for example 3000 is 30%

I performed something but don't how to perform percentile

```auto
{
  "query": {
    "range": {
      "response_code": {
        "gt": "3000"
      }
    }
  }
}

```

---

<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:** [September 18, 2022, 11:16pm UTC](https://discuss.elastic.co/t/show-number-as-percentile-in-elasticsearch-dsl/314506/2 "2022-09-18T23:16:58Z")

</div>

> [@Aniket\_Pant](#):
>
> Show response\_code as percentile

Percentile of what though?

---

<div class="post-metadata">

**Author:** ![Aniket\_Pant](https://avatars.discourse-cdn.com/v4/letter/a/77aa72/32.png) [@Aniket\_Pant](https://discuss.elastic.co/u/Aniket_Pant)\
**Post date:** [September 19, 2022, 4:44am UTC](https://discuss.elastic.co/t/show-number-as-percentile-in-elasticsearch-dsl/314506/3 "2022-09-19T04:44:02Z")

</div>

if response code is 3456 it percentile would be 34.56%. I have to perform this operation on ML if it reached to more than 10 % it would be treated as an anamoly.

---

<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:** [September 19, 2022, 4:54am UTC](https://discuss.elastic.co/t/show-number-as-percentile-in-elasticsearch-dsl/314506/4 "2022-09-19T04:54:24Z")

</div>

Why not alter that during ingestion, or add it on with a runtime field?

---

<div class="post-metadata">

**Author:** ![Aniket\_Pant](https://avatars.discourse-cdn.com/v4/letter/a/77aa72/32.png) [@Aniket\_Pant](https://discuss.elastic.co/u/Aniket_Pant)\
**Post date:** [September 19, 2022, 8:01am UTC](https://discuss.elastic.co/t/show-number-as-percentile-in-elasticsearch-dsl/314506/5 "2022-09-19T08:01:25Z")

</div>

Hi @warkolm in kibana visualization we have response code value as percentage.  
[How to display data as a percentage in Kibana visualization](https://www.elastic.co/blog/how-to-display-data-as-a-percentage-in-kibana-visualizations)

So i was thinking can we fetch those field either through KQL or normal query.

---

<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:** [September 19, 2022, 9:01am UTC](https://discuss.elastic.co/t/show-number-as-percentile-in-elasticsearch-dsl/314506/6 "2022-09-19T09:01:38Z")

</div>

Except that percentage calculation is done by an aggregation, not being taken directly from the data like you want to do.

---

<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:** [October 17, 2022, 9:02am UTC](https://discuss.elastic.co/t/show-number-as-percentile-in-elasticsearch-dsl/314506/7 "2022-10-17T09:02:01Z")

</div>

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