Splunk Search

How to calculate SUM by type?

Neel881
Path Finder

Hello everyone,

I am trying to SUM the columns. 

index="nzc-neel-uttar" source="http:kyhkp"
| timechart span=1d count by Type
| eval "New_Date"=strftime(_time,"%Y-%m-%d") 
_time Type-A Type-B New_Date
20/07/2023 3 8 20/07/2023
21/07/2023 4 23

21/07/2023

22/07/2023 66 0 22/07/2023
23/07/2023 90 0 23/07/2023
24/07/2023 0 6 24/07/2023
25/07/2023 0 23 25/07/2023

 

Desired Output:

New_Date Type-A Type-B Total
20/07/2023 3 8 11
21/07/2023 4 23 27
22/07/2023 66 0 66
23/07/2023 90 0 90
24/07/2023 0 6 6
25/07/2023 0 23 23

 

Please suggest

Thanks

Labels (6)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
index="nzc-neel-uttar" source="http:kyhkp"
| timechart span=1d count by Type
| addtotals row=t
| eval "New_Date"=strftime(_time,"%Y-%m-%d") 

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust
index="nzc-neel-uttar" source="http:kyhkp"
| timechart span=1d count by Type
| addtotals row=t
| eval "New_Date"=strftime(_time,"%Y-%m-%d") 

Neel881
Path Finder

Its working fine, thank you so much!

How to add others columns from the index? Ex: Phase from the same index.

New_DateType-AType-BTotalPhase
20/07/202338111
21/07/2023423271
22/07/2023660661
23/07/2023900901
24/07/20230661
25/07/202302323abc

 

Also, remove and rearrange the columns sequence, mentioned in the above table.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Unless Phase can be derived from your current results, you could potentially use appendcols, but it depends on your data.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...

Index This | How many sevens are there between 1 and 100?

August 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this ...