Splunk Search

## Is there a way to calculate the percentile of a value within a range of values?

Path Finder

One of the most useful functions in Excel is percentilerank, which calculates the percentile of a value within a range of values. The closest I've been able to get is to do a p10, p20, p30, etc. and then search for everything below the value. I'm trying to show benchmarks and the function would be quite useful.

If you're not familiar with the percentilerank function, it works as follows:

• You specify percentilerank(value, array of values)
• Percentile rank returns the percentile for that value (e.g., 23rd percentile)

It's basically the converse of the perc commands.

Tags (4)
1 Solution
SplunkTrust

This should be it:

... | stats count by value | sort + value
| streamstats current=f sum(count) as rank | fillnull rank
| eventstats sum(count) as total | eval percentile_rank = rank / total * 100

This will assign each unique value its absolute rank and then convert that to percentile rank using the total number of values.

SplunkTrust

This should be it:

... | stats count by value | sort + value
| streamstats current=f sum(count) as rank | fillnull rank
| eventstats sum(count) as total | eval percentile_rank = rank / total * 100

This will assign each unique value its absolute rank and then convert that to percentile rank using the total number of values.

Path Finder

Nice - it even accounts for duplicate values!

Legend

Have you tried any of these? p<X>(Y) | perc<X>(Y) | exactperc<X>(Y) | upperperc<X>(Y)

http://docs.splunk.com/Documentation/Splunk/6.4.3/SearchReference/CommonStatsFunctions

Get Updates on the Splunk Community!

#### 2024 Splunk Career Impact Survey | Earn a \$20 gift card for participating!

Hear ye, hear ye! The time has come again for Splunk's annual Career Impact Survey!  We need your help by ...

#### Optimize Cloud Monitoring

TECH TALKS Optimize Cloud Monitoring Tuesday, August 13, 2024  |  11:00AM–12:00PM PST   Register to ...

#### What's New in Splunk Cloud Platform 9.2.2403?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.2.2403! Analysts can ...