Splunk Search

How to edit my stats search to find the percentage of a range?

dcascione
Explorer

I'm trying to build a simple SPL query to display the max, min, range (difference), and percent of the difference to the max value.

index=myindex source="mysource"| stats max(count), min(count), range(count)|rename max(count) to "Max", min(count) to "Min", range(count) to "Difference"

Tried using the perc(y) stats function with no luck... Also tried some basic math which blows up every time..

range(count) \ max(count)*100 

Thanks for your help in advance.

0 Karma
1 Solution

javiergn
Super Champion

Hi, is count an existing field in your data?
If so try the following:

index=myindex source="mysource"
| stats max(count) as Max, min(count) as Min, range(count) as Difference
| eval Difference_Percent = Difference / Max * 100

If not, you need to calculate the value of count first (probably using stats count)

View solution in original post

0 Karma

javiergn
Super Champion

Hi, is count an existing field in your data?
If so try the following:

index=myindex source="mysource"
| stats max(count) as Max, min(count) as Min, range(count) as Difference
| eval Difference_Percent = Difference / Max * 100

If not, you need to calculate the value of count first (probably using stats count)

0 Karma

dcascione
Explorer

Yes -"count" is an existing field . This worked - Thanks for the answer!

0 Karma
Get Updates on the Splunk Community!

Index This | What’s a riddle wrapped in an enigma?

September 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this ...

BORE at .conf25

Boss Of Regular Expression (BORE) was an interactive session run again this year at .conf25 by the brilliant ...

OpenTelemetry for Legacy Apps? Yes, You Can!

This article is a follow-up to my previous article posted on the OpenTelemetry Blog, "Your Critical Legacy App ...