Splunk Search

Difference between today's and yesterday's data.

3666142
Path Finder

I am trying to find the difference between today and yesterday's data. The data consists of every employee's Id number and first/last name. So I just want to know if the company hired within the last day. This is the search query that I currently have. Does the "earliest" and "latest" format make sense (like the -1d@d). Also, if there is not a difference between the two days, how do I have Splunk display a chart that says, "No diff."? Thanks.

| set diff
[ search index="ABCD" (earliest=@d)
| table Employee_number First_name Last_name]
[ search index="ABCD" (earliest=-1d@d latest=@d-1)
| table Employee_number First_name Last_name]

0 Karma
1 Solution

adonio
Ultra Champion

for something like this a lookup might be better imho

another way to do it is maybe to search for the last couple of days, then check in how many unique days an ID appears
if 1 day, then it was hired that day, if greater, then one, it was there yesterday

something like this:
... index="ABCD" Employee_number=* | bin _time span=24h | stats dc(Employee_number) as new_or_not by _time
| eval new_or_not = if(new_or_not=="1","New Person","Long Time Employee") ...

hope it helps

View solution in original post

0 Karma

adonio
Ultra Champion

for something like this a lookup might be better imho

another way to do it is maybe to search for the last couple of days, then check in how many unique days an ID appears
if 1 day, then it was hired that day, if greater, then one, it was there yesterday

something like this:
... index="ABCD" Employee_number=* | bin _time span=24h | stats dc(Employee_number) as new_or_not by _time
| eval new_or_not = if(new_or_not=="1","New Person","Long Time Employee") ...

hope it helps

0 Karma

3666142
Path Finder

Thank you. That definitely put me in the right direction.

0 Karma
Get Updates on the Splunk Community!

Splunk Decoded: Service Maps vs Service Analyzer Tree View vs Flow Maps

It’s Monday morning, and your phone is buzzing with alert escalations – your customer-facing portal is running ...

What’s New in Splunk Observability – September 2025

What's NewWe are excited to announce the latest enhancements to Splunk Observability, designed to help ITOps ...

Fun with Regular Expression - multiples of nine

Fun with Regular Expression - multiples of nineThis challenge was first posted on Slack #regex channel ...