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
Happy Splunking!
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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

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