<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic compare record from yesterday to today if field equals in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/compare-record-from-yesterday-to-today-if-field-equals/m-p/583288#M203101</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Say I have a batch job that pushes JSON records that look like this on Monday:&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;{&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Department&lt;/SPAN&gt;:&amp;nbsp;&lt;SPAN class=""&gt;Engineering&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Employee_Number&lt;/SPAN&gt;:&amp;nbsp;&lt;SPAN class=""&gt;4642&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Employment_Status&lt;/SPAN&gt;: &lt;STRONG&gt;Active&lt;BR /&gt;&lt;/STRONG&gt;&amp;nbsp; &amp;nbsp;Termination_Date&lt;STRONG&gt;:&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN class=""&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp;Full_Name: Jane Doe&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;}&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;But on Tuesday A new record gets pushed like this:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;{&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;Department:&amp;nbsp;Engineering&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;Employee_Number:&amp;nbsp;4642&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;Employment_Status: &lt;STRONG&gt;Terminated&lt;BR /&gt;&lt;/STRONG&gt;&amp;nbsp; &amp;nbsp;Termination_Date&lt;STRONG&gt;:&amp;nbsp;&lt;/STRONG&gt;01/31/2022&lt;BR /&gt;&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp;Full_Name: Jane Doe&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;How would I create a search that would compare the "&lt;FONT face="courier new,courier"&gt;Employment Status&lt;/FONT&gt;"&amp;nbsp;&lt;EM&gt;For each record, and only return the records that transitioned to "&lt;STRONG&gt;Terminated&lt;/STRONG&gt;"&amp;nbsp; within the last 2 days?&lt;/EM&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I tried the following, but it's not working.&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;&lt;BR /&gt;index=myinventory sourcetype=HR earliest=-2d@d&lt;BR /&gt;| eventstats earliest(_time) as earliestEventTime by Employment_Status&lt;BR /&gt;| dedup FullName, Employment_Status&lt;BR /&gt;| where Employment_Status!="Active"&lt;BR /&gt;| table _time, earliestEventTime, FullName, Employment_Status&lt;BR /&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 02 Feb 2022 03:27:52 GMT</pubDate>
    <dc:creator>zachsisinst</dc:creator>
    <dc:date>2022-02-02T03:27:52Z</dc:date>
    <item>
      <title>compare record from yesterday to today if field equals</title>
      <link>https://community.splunk.com/t5/Splunk-Search/compare-record-from-yesterday-to-today-if-field-equals/m-p/583288#M203101</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Say I have a batch job that pushes JSON records that look like this on Monday:&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;{&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Department&lt;/SPAN&gt;:&amp;nbsp;&lt;SPAN class=""&gt;Engineering&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Employee_Number&lt;/SPAN&gt;:&amp;nbsp;&lt;SPAN class=""&gt;4642&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Employment_Status&lt;/SPAN&gt;: &lt;STRONG&gt;Active&lt;BR /&gt;&lt;/STRONG&gt;&amp;nbsp; &amp;nbsp;Termination_Date&lt;STRONG&gt;:&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN class=""&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp;Full_Name: Jane Doe&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;}&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;But on Tuesday A new record gets pushed like this:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;{&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;Department:&amp;nbsp;Engineering&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;Employee_Number:&amp;nbsp;4642&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;Employment_Status: &lt;STRONG&gt;Terminated&lt;BR /&gt;&lt;/STRONG&gt;&amp;nbsp; &amp;nbsp;Termination_Date&lt;STRONG&gt;:&amp;nbsp;&lt;/STRONG&gt;01/31/2022&lt;BR /&gt;&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp;Full_Name: Jane Doe&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;How would I create a search that would compare the "&lt;FONT face="courier new,courier"&gt;Employment Status&lt;/FONT&gt;"&amp;nbsp;&lt;EM&gt;For each record, and only return the records that transitioned to "&lt;STRONG&gt;Terminated&lt;/STRONG&gt;"&amp;nbsp; within the last 2 days?&lt;/EM&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I tried the following, but it's not working.&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;&lt;BR /&gt;index=myinventory sourcetype=HR earliest=-2d@d&lt;BR /&gt;| eventstats earliest(_time) as earliestEventTime by Employment_Status&lt;BR /&gt;| dedup FullName, Employment_Status&lt;BR /&gt;| where Employment_Status!="Active"&lt;BR /&gt;| table _time, earliestEventTime, FullName, Employment_Status&lt;BR /&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Feb 2022 03:27:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/compare-record-from-yesterday-to-today-if-field-equals/m-p/583288#M203101</guid>
      <dc:creator>zachsisinst</dc:creator>
      <dc:date>2022-02-02T03:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: compare record from yesterday to today if field equals</title>
      <link>https://community.splunk.com/t5/Splunk-Search/compare-record-from-yesterday-to-today-if-field-equals/m-p/583290#M203103</link>
      <description>&lt;P&gt;You could do something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=myinventory sourcetype=HR earliest=-2d@d
| stats values(Employment_Status) as Employment_Status latest(Employment_Status) as Last_Status values(FullName) as FullName by Employee_Number
| where mvcount(Employment_Status)&amp;gt;1 and Last_Status="Terminated"&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 01 Feb 2022 22:41:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/compare-record-from-yesterday-to-today-if-field-equals/m-p/583290#M203103</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-02-01T22:41:21Z</dc:date>
    </item>
    <item>
      <title>Re: compare record from yesterday to today if field equals</title>
      <link>https://community.splunk.com/t5/Splunk-Search/compare-record-from-yesterday-to-today-if-field-equals/m-p/583297#M203108</link>
      <description>&lt;P&gt;And simple search for Employment_Status="Terminated" is not enough because?&lt;/P&gt;&lt;P&gt;Btw, -2d@d is not "last 24h"&lt;/P&gt;</description>
      <pubDate>Tue, 01 Feb 2022 23:20:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/compare-record-from-yesterday-to-today-if-field-equals/m-p/583297#M203108</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-02-01T23:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: compare record from yesterday to today if field equals</title>
      <link>https://community.splunk.com/t5/Splunk-Search/compare-record-from-yesterday-to-today-if-field-equals/m-p/583301#M203112</link>
      <description>&lt;P&gt;Because the previous day might also be terminated not active?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Feb 2022 23:41:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/compare-record-from-yesterday-to-today-if-field-equals/m-p/583301#M203112</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-02-01T23:41:16Z</dc:date>
    </item>
    <item>
      <title>Re: compare record from yesterday to today if field equals</title>
      <link>https://community.splunk.com/t5/Splunk-Search/compare-record-from-yesterday-to-today-if-field-equals/m-p/583313#M203117</link>
      <description>&lt;P&gt;This works great! Thank you!!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Feb 2022 03:30:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/compare-record-from-yesterday-to-today-if-field-equals/m-p/583313#M203117</guid>
      <dc:creator>zachsisinst</dc:creator>
      <dc:date>2022-02-02T03:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: compare record from yesterday to today if field equals</title>
      <link>https://community.splunk.com/t5/Splunk-Search/compare-record-from-yesterday-to-today-if-field-equals/m-p/583326#M203119</link>
      <description>&lt;P&gt;Here's a different approach. Since you have the termination date in the daily update, you can simply key off of that and calculate where term_age_days=1.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=myinventory sourcetype=HR earliest=-1d@d
| search Employment_Status="Terminated"
| eval term_age_days=ROUND((RELATIVE_TIME(NOW(),"-0d@d")-STRPTIME(Termination_Date, "%m/%d/%Y"))/86400)
| where term_age_days=1
| table _time, FullName, Employment_Status, Termination_Date, term_age_days&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Feb 2022 07:11:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/compare-record-from-yesterday-to-today-if-field-equals/m-p/583326#M203119</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-02-02T07:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: compare record from yesterday to today if field equals</title>
      <link>https://community.splunk.com/t5/Splunk-Search/compare-record-from-yesterday-to-today-if-field-equals/m-p/583350#M203128</link>
      <description>&lt;P&gt;Ahh, OK. That was not obvious from the initial specifications. We only want the accounts that returned some other status as well as "Terminated"? But that's not very well specified since "Transitioned to Terminated within last 2 days" might as well mean that the account was Active just before our search range and transitioned to Terminated right at the beginning of it. If there is a guarantee that we have at least one event per day per single account, everything should be ok as long as we extend a bit the search range and check the last Terminated timestamp. But if not - that's different use case.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Feb 2022 09:22:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/compare-record-from-yesterday-to-today-if-field-equals/m-p/583350#M203128</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-02-02T09:22:52Z</dc:date>
    </item>
  </channel>
</rss>

