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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...