Splunk Search

How do I create an evaluated expression based on an aggregate in the Pivot?

chustar
Path Finder

I'm currently building a report using Pivot tables. I'm trying to get my data model to look like this:

GroupName    AverageAge   AverageGrade    AverageAgeGreaterThan35
GroupA            30        90             False
GroupB            40        12             True

In this case, the AverageAgeGreaterThan35 column would be an evaluated expression.
I've tried doing this using an evaluated expression but it evaluates for each value, not the average value.
Is there a way to write the evaluated expression to support this?

Tags (4)
0 Karma
1 Solution

chustar
Path Finder

After reading this answer by gkanapathy (http://answers.splunk.com/answers/34208/eval-mean-something-when-data-is-split-by-another-field.html... ) I came to the solution.

What I did was use eventstats to add the average first, and then use stats and eval to build up my string. Something like this:

* | eventstats avg(Age) as CalcAvgAvge by GroupName | stats first(eval(if(CalcAvgAvge>35, "True", "False"))) AS AverageAgeGreaterThan35, avg(Age) as AverageAge, avg(Grade) as AverageGrade by GroupName,

View solution in original post

chustar
Path Finder

After reading this answer by gkanapathy (http://answers.splunk.com/answers/34208/eval-mean-something-when-data-is-split-by-another-field.html... ) I came to the solution.

What I did was use eventstats to add the average first, and then use stats and eval to build up my string. Something like this:

* | eventstats avg(Age) as CalcAvgAvge by GroupName | stats first(eval(if(CalcAvgAvge>35, "True", "False"))) AS AverageAgeGreaterThan35, avg(Age) as AverageAge, avg(Grade) as AverageGrade by GroupName,
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...