Splunk Dev

issue in sum chart and addcoltotals

ND
Path Finder

Hi All,

I want to show sum of field by year(2019, 2020, 2021)

i am using query:

|inputlookup abc.csv | eval _time=strptime('date1',"%Y-%m-%d")| eval year= strftime(_time,"%Y")  | chart sum(com) as com by field1, year| addcoltotals

o/p:

field1 com 2019 2020 2021 

for this total for 2020 is correct but facing issue for 2019 & 2021

please help me to get correct solution for this.

Thank,

ND

Labels (2)
0 Karma
1 Solution

PickleRick
SplunkTrust
SplunkTrust

What "issue" are you facing? Are the rows incorrectly associated with proper years? Is the sum incorrectly counted?

Oh, and instead of strptime and strftime, you could just do

| eval year=substr(date1,1,4)

View solution in original post

0 Karma

PickleRick
SplunkTrust
SplunkTrust

What "issue" are you facing? Are the rows incorrectly associated with proper years? Is the sum incorrectly counted?

Oh, and instead of strptime and strftime, you could just do

| eval year=substr(date1,1,4)
0 Karma

ND
Path Finder

yes ,the sum incorrectly counted, for  year 2019 and 202. but sum for 2020 is correctly counted.

the data is correctly associated 

| eval year=substr(date1,1,4) thanks will update this.
0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

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

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...