<?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 Re: Subsearch Question in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-Question/m-p/120718#M32441</link>
    <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;P&gt;This will give your list of persons appearing only on this week's report&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=sensitive host=ActiveEmployeeList earliest=-7d@w1 [search index=sensitive host=ActiveEmployeeList earliest=-7d@w1 | stats first(_time) as _time] | eventstats count by EEN | where count=1 | table _time EEN Last_Name First_Name Job_Title | sort by EEN
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will give your list of persons appearing only on previous week's report&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=sensitive host=ActiveEmployeeList earliest=-7d@w1 [search index=sensitive host=ActiveEmployeeList earliest=-7d@w1 | stats last(_time) as _time] | eventstats count by EEN | where count=1 | table _time EEN Last_Name First_Name Job_Title | sort by EEN
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Updated answer:&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=sensitive host=ActiveEmployeeList earliest=-7d@w1 [search index=sensitive host=ActiveEmployeeList earliest=-7d@w1 | table EEN Last_Name | stats count, first(_time) as _time by EEN | where count=1 | eventstats max(_time) as currentWeekTime | where _time=currentWeekTime | table EEN | format] | table _time EEN Last_Name First_Name Job_Title | sort by EEN
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I am doing here is that along with unique EEN, I am getting their _time value as well in subsearch. Then within subsearch itself taking the max value of _time which will be current week timestamp and then filtering EEN from current week only. &lt;/P&gt;</description>
    <pubDate>Fri, 04 Apr 2014 18:01:03 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2014-04-04T18:01:03Z</dc:date>
    <item>
      <title>Subsearch Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-Question/m-p/120717#M32440</link>
      <description>&lt;P&gt;Some background information on this. I have a CSV file that is being loaded every Monday. There are no time stamps in the file so everything has a time stamp of when the file was loaded. I set up my search to compare the previous file loaded vs the most recent. The current search I have will display a person if they show up on the previous report or the new one. I want to split these out into two separate searches. However, the only unique value that I can use to do this is the "_time". Can someone how me figure out a statement to add so I only pull results that has a time stamp the most recent file. Keep in mind I don't have a specific time that the file will be loaded. &lt;/P&gt;

&lt;P&gt;**One important note, I'm comparing two files but at any given point there are ONLY 2 total time stamps present no matter how many logs each file has. Because when Splunk loads the file it's loading it with the current time it was loaded.&lt;/P&gt;

&lt;P&gt;I was hoping I could use a where statement and for the value of @w1 but it's not possible.&lt;/P&gt;

&lt;P&gt;index=sensitive host=ActiveEmployeeList earliest=-7d@w1 [search index=sensitive host=ActiveEmployeeList earliest=-7d@w1 | table EEN Last_Name | stats count by EEN | where count=1 | table EEN | format] | table _time EEN Last_Name First_Name Job_Title | sort by EEN&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:19:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-Question/m-p/120717#M32440</guid>
      <dc:creator>Phynyte</dc:creator>
      <dc:date>2020-09-28T16:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-Question/m-p/120718#M32441</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;P&gt;This will give your list of persons appearing only on this week's report&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=sensitive host=ActiveEmployeeList earliest=-7d@w1 [search index=sensitive host=ActiveEmployeeList earliest=-7d@w1 | stats first(_time) as _time] | eventstats count by EEN | where count=1 | table _time EEN Last_Name First_Name Job_Title | sort by EEN
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will give your list of persons appearing only on previous week's report&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=sensitive host=ActiveEmployeeList earliest=-7d@w1 [search index=sensitive host=ActiveEmployeeList earliest=-7d@w1 | stats last(_time) as _time] | eventstats count by EEN | where count=1 | table _time EEN Last_Name First_Name Job_Title | sort by EEN
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Updated answer:&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=sensitive host=ActiveEmployeeList earliest=-7d@w1 [search index=sensitive host=ActiveEmployeeList earliest=-7d@w1 | table EEN Last_Name | stats count, first(_time) as _time by EEN | where count=1 | eventstats max(_time) as currentWeekTime | where _time=currentWeekTime | table EEN | format] | table _time EEN Last_Name First_Name Job_Title | sort by EEN
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I am doing here is that along with unique EEN, I am getting their _time value as well in subsearch. Then within subsearch itself taking the max value of _time which will be current week timestamp and then filtering EEN from current week only. &lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2014 18:01:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-Question/m-p/120718#M32441</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-04-04T18:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-Question/m-p/120719#M32442</link>
      <description>&lt;P&gt;That doesn't work. I think the subsearch needs to contain the "stats count by EEN | where count=1" because that portion compares the two files and removes all of the duplicates.&lt;/P&gt;

&lt;P&gt;Then Once I have those EEN's my outer search will need to somehow split the times up.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2014 18:31:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-Question/m-p/120719#M32442</guid>
      <dc:creator>Phynyte</dc:creator>
      <dc:date>2014-04-04T18:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-Question/m-p/120720#M32443</link>
      <description>&lt;P&gt;To try and simplify this query i'm trying to write. I'm trying to do 3 things.&lt;BR /&gt;
 1. Find the EEN's that only appear 1 time when comparing the 2 files &lt;BR /&gt;
 2. Once those EEN's are found there are 2 possible time stamps that can be associated. One for new employees and one for people who are no longer employeed. &lt;BR /&gt;
 3. My goal is to separate those 2 groups by the only unique field between them (time stamp). So all new employees will have Time stamp A and the others time stamp B.&lt;BR /&gt;
-The challenging part is I can' specify a specific time because this is going to run weekly from Monday to Monday.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2014 19:01:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-Question/m-p/120720#M32443</guid>
      <dc:creator>Phynyte</dc:creator>
      <dc:date>2014-04-04T19:01:54Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-Question/m-p/120721#M32444</link>
      <description>&lt;P&gt;I guess your current query does 1 and 2 already. For segregation of new employees (with timestamp of this weeks monday) and no-longer-employee (from previous monday's report), (since your said there will be only two possible value of timestamps), your can add '| eventstats max(_time) as CurrentWeek min(_time) as PreviousWeek | eval employeeType=case(_time=CurrentWeek,"New Employee",_time=PreviousWeek,"Terminated Employees") | fields - CurrentWeek, PreviousWeek' to your existing search.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:19:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-Question/m-p/120721#M32444</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-28T16:19:26Z</dc:date>
    </item>
  </channel>
</rss>

