<?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: Complex subsearch comparing time periods in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Complex-subsearch-comparing-time-periods/m-p/333176#M99088</link>
    <description>&lt;P&gt;This may only be a partial answer, but your subsearch needs to be changed.  It currently results in a field named &lt;CODE&gt;values(mdn)&lt;/CODE&gt;, which is unlikely to be in your source data.  Also, multivalue fields returned from a subsearch aren't that simple, so try splitting them up via mvexpand:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[search sourcetype=abc KPI100 earliest=05/11/2017:00:00:00 lastest=now results=completed.jsp | stats values(mdn) AS mdn | mvexpand mdn]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Edit: I'm going to attempt to answer the full question since the partial answer didn't work.&lt;/P&gt;

&lt;P&gt;I would suggest trying to do this all in one search, going back the full 20 days, and reporting based on all of that data.  It might look something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=abc KPI100 earliest=-20d latest=now result=completed.jsp
| addinfo 
| eval twenty_days_ago=relative_time(info_max_time, "-20d@d") 
| eval was_in_last_twenty_days=if(_time &amp;gt;= twenty_days_ago, 1, 0) 
| eventstats dc(was_in_last_twenty_days) AS dc_was_in_last_twenty_days, count BY mdn
| search dc_was_last_twenty_days&amp;gt;1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should give you the count for &lt;CODE&gt;mdn&lt;/CODE&gt; values that were seen in both time periods (-20d -&amp;gt; -10d, -10d -&amp;gt; now).  This might not be exactly what you want, but it might be enough to get you going.&lt;/P&gt;</description>
    <pubDate>Thu, 01 Jun 2017 15:53:26 GMT</pubDate>
    <dc:creator>micahkemp</dc:creator>
    <dc:date>2017-06-01T15:53:26Z</dc:date>
    <item>
      <title>Complex subsearch comparing time periods</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Complex-subsearch-comparing-time-periods/m-p/333175#M99087</link>
      <description>&lt;P&gt;Hello I have a rather complex search/subsearch I am trying to figure out.&lt;/P&gt;

&lt;P&gt;I need to acquire a list of values from a search from 20 days ago to 10 days ago.&lt;BR /&gt;
A search such as: &lt;BR /&gt;
sourcetype=abc KPI100 earliest=05/11/2017:00:00:00 latest=now result=completed.jsp | stats values(mdn)&lt;/P&gt;

&lt;P&gt;And I need to use those results and query them with another query that will run from 10 days ago to present and show the ones who have a count &amp;gt; 1 such as;&lt;BR /&gt;
sourcetype=xyz KPI200 | table VAL | eventstats counts by VAL | search count&amp;gt;1 | dedup VAL&lt;/P&gt;

&lt;P&gt;So I tried to create a subsearch as:&lt;BR /&gt;
sourcetype=xyz KPI200 [serach sourcetype=abc KPI100 earliest=05/11/2017:00:00:00 lastest=now results=completed.jsp | stats values(mdn)] | table VAL | eventstats count by VAL | search count&amp;gt;1 | dedup VAL&lt;BR /&gt;
But it didn't return any values.&lt;/P&gt;

&lt;P&gt;Any suggestions?&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2017 15:49:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Complex-subsearch-comparing-time-periods/m-p/333175#M99087</guid>
      <dc:creator>EricLloyd79</dc:creator>
      <dc:date>2017-06-01T15:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: Complex subsearch comparing time periods</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Complex-subsearch-comparing-time-periods/m-p/333176#M99088</link>
      <description>&lt;P&gt;This may only be a partial answer, but your subsearch needs to be changed.  It currently results in a field named &lt;CODE&gt;values(mdn)&lt;/CODE&gt;, which is unlikely to be in your source data.  Also, multivalue fields returned from a subsearch aren't that simple, so try splitting them up via mvexpand:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[search sourcetype=abc KPI100 earliest=05/11/2017:00:00:00 lastest=now results=completed.jsp | stats values(mdn) AS mdn | mvexpand mdn]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Edit: I'm going to attempt to answer the full question since the partial answer didn't work.&lt;/P&gt;

&lt;P&gt;I would suggest trying to do this all in one search, going back the full 20 days, and reporting based on all of that data.  It might look something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=abc KPI100 earliest=-20d latest=now result=completed.jsp
| addinfo 
| eval twenty_days_ago=relative_time(info_max_time, "-20d@d") 
| eval was_in_last_twenty_days=if(_time &amp;gt;= twenty_days_ago, 1, 0) 
| eventstats dc(was_in_last_twenty_days) AS dc_was_in_last_twenty_days, count BY mdn
| search dc_was_last_twenty_days&amp;gt;1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should give you the count for &lt;CODE&gt;mdn&lt;/CODE&gt; values that were seen in both time periods (-20d -&amp;gt; -10d, -10d -&amp;gt; now).  This might not be exactly what you want, but it might be enough to get you going.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2017 15:53:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Complex-subsearch-comparing-time-periods/m-p/333176#M99088</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2017-06-01T15:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: Complex subsearch comparing time periods</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Complex-subsearch-comparing-time-periods/m-p/333177#M99089</link>
      <description>&lt;P&gt;Thanks for the suggestion.&lt;BR /&gt;
It still returns nothing.  I continue to search for a solution.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2017 18:43:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Complex-subsearch-comparing-time-periods/m-p/333177#M99089</guid>
      <dc:creator>EricLloyd79</dc:creator>
      <dc:date>2017-06-01T18:43:52Z</dc:date>
    </item>
    <item>
      <title>Re: Complex subsearch comparing time periods</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Complex-subsearch-comparing-time-periods/m-p/333178#M99090</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=xyz KPI200 [search sourcetype=abc KPI100 earliest=-20d@d latest=-10d@d result=completed.jsp | stats count by mdn | table mdn]
| stats count by VAL| where count&amp;gt;1 | table VAL
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Jun 2017 20:39:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Complex-subsearch-comparing-time-periods/m-p/333178#M99090</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-06-01T20:39:38Z</dc:date>
    </item>
  </channel>
</rss>

