Splunk Search

how can i calculate the average time range of DayOne,DayTwo,DayThree for each student_id?

pavanae
Builder

I have a splunk Query as below

earliest=-1d@d latest=@d index=abc | where date_hour>=15 OR date_hour<9 | stats earliest(date_hour) as FirstHour latest(date_hour) as LastHour by student_id|eval DayOne=FirstHour+" to "+LastHour| fields - FirstHour - FirstMinute - LastHour - LastMinute | appendcols [search earliest=-2d@d latest=-1d@d index=abc | where date_hour>=15 OR date_hour<9 | stats earliest(date_hour) as FirstHour latest(date_hour) as LastHour by student_id|eval DayTwo=FirstHour+" to "+LastHour| fields - FirstHour - FirstMinute - LastHour - LastMinute ] | appendcols [search earliest=-3d@d latest=-2d@d index=abc | where date_hour>=15 OR date_hour<9 | stats earliest(date_hour) as FirstHour latest(date_hour) as LastHour by student_id|eval DayThree=FirstHour+" to "+LastHour| fields - FirstHour - FirstMinute - LastHour - LastMinute ]| table student_id DayOne DayTwo DayThree

Which displays the result as below

student_id DayOne DayTwo DayThree
A123 22--24 19--23 20--22
B456 02--08 03--07 19--00

Hint 1 :- I have used 3 searches above which are same except for the fields DayOne,DayTwo,DayThree and earliest,latest times.

Note :- If calcullating average for this scenario isn't possible. Any ideas or suggestions would highly appriciate. Thank you.

Now how can i calculate the average time range of DayOne,DayTwo,DayThree for each student_id?

0 Karma

gokadroid
Motivator

Looks like the average calculation for your data set was already provided which you had accepted as an answer too, here:
https://answers.splunk.com/answers/475177/how-to-calculate-the-average-and-standard-deviatio.html

Also in this answer you have given a way to calculate the average yourself:
https://answers.splunk.com/answers/476004/how-to-compare-the-last-7-days-average-with-yester.html

Also as a comment to your scenario, you were not able to provide, what is the expected "average" that you wanted?
https://answers.splunk.com/answers/475177/how-to-calculate-the-average-and-standard-deviatio.html#co...

So unless you do not articulate what is meant by an average of the two dimensional data set that you provide then it might be hard to answer or to calculate it by community users.

0 Karma
Get Updates on the Splunk Community!

Index This | Forward, I’m heavy; backward, I’m not. What am I?

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

A Guide To Cloud Migration Success

As enterprises’ rapid expansion to the cloud continues, IT leaders are continuously looking for ways to focus ...

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...