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
SplunkTrust
SplunkTrust

@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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...