Splunk Search

How do you calculate the average for a chart count over table?

cfstoica
New Member

How do you add another column that contains averages based on previous columns after "chart count over Level by Month"?

Level Month1 Month2 Month3 Average
1 2 3 4 3
2 4 5 6 5
3 4 6 8 6
....

0 Karma

renjith_nair
Legend

@cfstoica,

If the number of months are dynamic, then give this a try,

chart count over Level by Month|addtotals|eval Total=Total-Level|eval colcount=-3
|foreach * [eval colcount=colcount+1]|eval Average=Total/colcount|fields - Total,colcount
---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma

kmorris_splunk
Splunk Employee
Splunk Employee

Is it always the same columns? You could do something like the following if so:

... | eval avgbylevel=(Month1 + Month2 + Month3)/3 | table Level Month1 Month2 Month3 avgbylevel
0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...