<?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: How to pass earliest and latest in search time using inputlookup in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-earliest-and-latest-in-search-time-using-inputlookup/m-p/470514#M192151</link>
    <description>&lt;P&gt;Check if this query works for you. Note that below query sets &lt;CODE&gt;this_week_start&lt;/CODE&gt; to &lt;STRONG&gt;2020/04/06 00:00:00&lt;/STRONG&gt; (starting this Monday) and &lt;CODE&gt;last_week_start&lt;/CODE&gt; to &lt;STRONG&gt;2020/03/30 00:00:00&lt;/STRONG&gt; (starting previous week Monday) when I posted this answer.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup sample.csv 
| eval _time=strptime(_time, "%Y/%m/%d %H:%M:%S"), this_week_start=relative_time(now(), "@w1"), last_week_start=relative_time(now(), "-w@w1"), week = case(_time &amp;gt; this_week_start, "thisweek", _time &amp;gt; last_week_start, "lastweek", 1==1, "prior week") 
| stats count by test, week
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 09 Apr 2020 17:14:57 GMT</pubDate>
    <dc:creator>manjunathmeti</dc:creator>
    <dc:date>2020-04-09T17:14:57Z</dc:date>
    <item>
      <title>How to pass earliest and latest in search time using inputlookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-earliest-and-latest-in-search-time-using-inputlookup/m-p/470513#M192150</link>
      <description>&lt;P&gt;Hi Experts, I have a one month data inputlookup file i.e, sample.csv which contains two fields &lt;STRONG&gt;test&lt;/STRONG&gt; and &lt;STRONG&gt;_time&lt;/STRONG&gt;. I want to compare weekly data.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;sample.csv&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;test     _time&lt;BR /&gt;
101      202/04/02 14:02:18&lt;BR /&gt;
102      202/04/01 20:21:50&lt;BR /&gt;
101      202/04/05 02:09:12&lt;BR /&gt;
101      202/03/31 08:11:29&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Expected output:&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;test        count   week&lt;BR /&gt;
101           2            thisweek&lt;BR /&gt;
102           1              lastweek&lt;BR /&gt;
103            1            prior week&lt;BR /&gt;
101            1              prior week                      &lt;/P&gt;

&lt;P&gt;like this.. please help on this and thanks in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Apr 2020 12:52:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-pass-earliest-and-latest-in-search-time-using-inputlookup/m-p/470513#M192150</guid>
      <dc:creator>james_n</dc:creator>
      <dc:date>2020-04-09T12:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass earliest and latest in search time using inputlookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-earliest-and-latest-in-search-time-using-inputlookup/m-p/470514#M192151</link>
      <description>&lt;P&gt;Check if this query works for you. Note that below query sets &lt;CODE&gt;this_week_start&lt;/CODE&gt; to &lt;STRONG&gt;2020/04/06 00:00:00&lt;/STRONG&gt; (starting this Monday) and &lt;CODE&gt;last_week_start&lt;/CODE&gt; to &lt;STRONG&gt;2020/03/30 00:00:00&lt;/STRONG&gt; (starting previous week Monday) when I posted this answer.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup sample.csv 
| eval _time=strptime(_time, "%Y/%m/%d %H:%M:%S"), this_week_start=relative_time(now(), "@w1"), last_week_start=relative_time(now(), "-w@w1"), week = case(_time &amp;gt; this_week_start, "thisweek", _time &amp;gt; last_week_start, "lastweek", 1==1, "prior week") 
| stats count by test, week
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Apr 2020 17:14:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-pass-earliest-and-latest-in-search-time-using-inputlookup/m-p/470514#M192151</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-04-09T17:14:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass earliest and latest in search time using inputlookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-earliest-and-latest-in-search-time-using-inputlookup/m-p/470515#M192152</link>
      <description>&lt;P&gt;@manjunathmeti , Thanks for the quick response, but this not working. all results showing as prior week only that to total count for 30days.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2020 11:04:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-pass-earliest-and-latest-in-search-time-using-inputlookup/m-p/470515#M192152</guid>
      <dc:creator>james_n</dc:creator>
      <dc:date>2020-04-10T11:04:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass earliest and latest in search time using inputlookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-earliest-and-latest-in-search-time-using-inputlookup/m-p/470516#M192153</link>
      <description>&lt;P&gt;sample:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="test time
101 2020/04/02 14:02:18
102 2020/04/01 20:21:50
101 2020/04/05 02:09:12
101 2020/03/31 08:11:29"
| multikv forceheader=1
| eval _time=strptime(time,"%Y/%m/%d %T")
| eval today = now()
| eval daysago=mvindex(split(tostring(today - _time,"duration"),"+"),0)
| eval week=case(daysago&amp;lt;=7,"thisweek",daysago &amp;gt; 7 AND daysago &amp;lt;= 14 ,"lastweek" , true(), "prior week")
| stats count by test week
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Recommend:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup sample.csv 
| eval _time=strptime(time,"%Y/%m/%d %T")
| eval today = now()
| eval daysago=mvindex(split(tostring(today - _time,"duration"),"+"),0)
| eval week=case(daysago&amp;lt;=7,"thisweek",daysago &amp;gt; 7 AND daysago &amp;lt;= 14 ,"lastweek" , true(), "prior week")
| stats count by test week
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How about this?&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2020 11:24:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-pass-earliest-and-latest-in-search-time-using-inputlookup/m-p/470516#M192153</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-10T11:24:12Z</dc:date>
    </item>
  </channel>
</rss>

