Splunk Search

How to Calculate the difference between two rows of a column?

Splunk_321
Path Finder

I have a splunk query shown below.

 

 

 

basesearch
| stats avg(time) as executionTime by method

 

 

 

which results in table like below

 

 

 

method               executionTime
A                        110.350
B                         90.150

 

 

 

I want to obtain executionTime difference between method A and B in a table result

A-B = 20.20

Please help me with splunk query to get the same.

Thanks in advance!

Labels (1)
Tags (2)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Splunk_321,

you have to put them in the same row, something like this:

basesearch
| stats 
   avg(eval(if(method="A"),time,0)) as executionTime_A
   avg(eval(if(method="B"),time,0)) as executionTime_B
| eval diff=executionTime_B-executionTime_A

Ciao.

Giuseppe

0 Karma
Get Updates on the Splunk Community!

.conf25 Community Recap

Hello Splunkers, And just like that, .conf25 is in the books! What an incredible few days — full of learning, ...

Splunk App Developers | .conf25 Recap & What’s Next

If you stopped by the Builder Bar at .conf25 this year, thank you! The retro tech beer garden vibes were ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...