# DQL - get percentile of a value

**URL:** <https://community.dynatrace.com/t/dql-get-percentile-of-a-value/49259>\
**Category:** DQL\
**Tags:** dql\
**Created:** [December 9, 2024, 11:10am UTC](https://community.dynatrace.com/t/dql-get-percentile-of-a-value/49259 "2024-12-09T11:10:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paolo\_fumanelli](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/paolo_fumanelli/32/1037_2.png) [@paolo\_fumanelli](https://community.dynatrace.com/u/paolo_fumanelli)\
**Post date:** [December 9, 2024, 11:10am UTC](https://community.dynatrace.com/t/dql-get-percentile-of-a-value/49259/1 "2024-12-09T11:10:43Z")

</div>

Hi DQLers, our tenant is strongly tag-oriented and we tagged almost each detected service with a key:value tag that allows us to assign each service to a specific application (and, in turn, to an application development team).

We’re now building a dashboard that acts as an application scorecard with some kpi for each application: managed calls, topology (calls, called by), error rate etc…

I’d like to highlight the “weight” of this application among all monitored ones. So I’d like to measure the percentile of an application managed requests.

Practical example. Let’s say we have 100 different applications and their managed requests in a timeframe (sort descending):  
App\_ABC 10 000  
App\_XYZ 8 500  
App\_QWE 7 000  
…  
…  
…

App\_ZXC 100

For application App\_XYZ I’d like to find DQL code to get that App\_XYZ represents 2nd percentile of applications managed requests.

How can I get this?

I know I can get the value of any percentile but in this case I need to work on the other side.

Any clue?

Thanks!  
Paolo

---

<div class="post-metadata">

**Author:** ![krzysztof\_hoja](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/krzysztof_hoja/32/34625_2.png) [@krzysztof\_hoja](https://community.dynatrace.com/u/krzysztof_hoja)\
**Post date:** [December 10, 2024, 8:59am UTC](https://community.dynatrace.com/t/dql-get-percentile-of-a-value/49259/2 "2024-12-10T08:59:17Z")

</div>

I think what you are looking for is an index of application in an array of all applications sorter by number of requests. And this index should be expressed not as a absolute value, but as percentage vs. whole array size.

Such query on test data looks like this:

```markup
data
  record(application="App_ABC", requests=10000),
  record(application="App_XYZ", requests=8500),
  record(application="App_QWE", requests=7000),
  record(application="App_ZXC", requests=100)
| summarize { d=collectArray(record(requests, application)) } 
| fieldsAdd d = arraySort(d, direction:"descending")
| fieldsAdd d = d[][application]
| fieldsAdd p = arrayIndexOf(d,"App_XYZ")
| fieldsAdd p = 100.0*p/arraySize(d)

```

 ![krzysztof_hoja_0-1733821062693.png](https://global.discourse-cdn.com/dynatrace/original/3X/2/e/2e922b15e24d0422c537f6d46ead295722299c72.png)

---

<div class="post-metadata">

**Author:** ![paolo\_fumanelli](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/paolo_fumanelli/32/1037_2.png) [@paolo\_fumanelli](https://community.dynatrace.com/u/paolo_fumanelli)\
**Post date:** [December 10, 2024, 2:11pm UTC](https://community.dynatrace.com/t/dql-get-percentile-of-a-value/49259/3 "2024-12-10T14:11:05Z")

</div>

That’s great! It fits perfectly my use case. Thanks a lot
