Splunk Search

How to get a year over year comparison in a search?

myahes
Explorer

using this articles advice (http://blogs.splunk.com/2012/02/19/compare-two-time-ranges-in-one-report/)

i am trying to compare year over year using the following search

index="stacks" earliest=-2mon@mon latest=-1mon@mon| multikv| eval ReportKey="thisYear"| append [search index="stacks" earliest=-14mon@mon latest=-13mon@mon| multikv| eval ReportKey="lastYear"]| timechart distinct_count(Check_Number) AS Check_Count, sum(Amount) AS "Net_Sales" by ReportKey

this generates the side by side data fine. when I add the eval modifier (eval

index="stacks" earliest=-2mon@mon latest=-1mon@mon| multikv| eval ReportKey="thisYear"| append [search index="stacks" earliest=-14mon@mon latest=-13mon@mon| multikv| eval ReportKey="lastYear" | eval _time=_time+60*60*24*365]| timechart distinct_count(Check_Number) AS Check_Count, sum(Amount) AS "Net_Sales" by ReportKey

The previous years data craps out.

Any idea what i am doing wrong?

Tags (3)
0 Karma

gkanapathy
Splunk Employee
Splunk Employee

It might be easier to use this app by David Carasso, Timewrap.

https://apps.splunk.com/app/1645/

0 Karma

myahes
Explorer

thank for responding. have you used it? i have tried using the timewrap y command and it doesnt work for me. only get the current year returned.

0 Karma
Get Updates on the Splunk Community!

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...