Splunk Search

Group data 'n' rows at a time

nikita012
New Member

I have 40 rows in my data with fields Date, Total. I want to add the values of Total for each 5 days. How can I group data 5 rows at a time?

0 Karma
1 Solution

renjith_nair
Legend

@nikita012,

Try this,

"your current search"
|streamstats count as rowno|eval _fives=if((rowno-1)%5==0,1,0)
|accum _fives as group|eventstats sum(total) by group

you may replace eventstats with stats if you do not want other fields

---
What goes around comes around. If it helps, hit it with Karma 🙂

View solution in original post

renjith_nair
Legend

@nikita012,

Try this,

"your current search"
|streamstats count as rowno|eval _fives=if((rowno-1)%5==0,1,0)
|accum _fives as group|eventstats sum(total) by group

you may replace eventstats with stats if you do not want other fields

---
What goes around comes around. If it helps, hit it with Karma 🙂
Get Updates on the Splunk Community!

SOCin’ it to you at Splunk University

Splunk University is expanding its instructor-led learning portfolio with dedicated Security tracks at .conf25 ...

Credit Card Data Protection & PCI Compliance with Splunk Edge Processor

Organizations handling credit card transactions know that PCI DSS compliance is both critical and complex. The ...

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

What are Community Office Hours?Community Office Hours is an interactive 60-minute Zoom series where ...