<?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: Filtering with the week number in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Filtering-with-the-week-number/m-p/291780#M55603</link>
    <description>&lt;P&gt;I think I'm reading your question differently than the others who've answered. It looks to me like you want to be able to add some options into the time filter dropdown to allow users to search for events by week number. The good news: this is possible. The bad news: I don't think it's possible to do this by adding to the regular timepicker. But if you want a dashboard where the time filters are done in a custom dropdown that allows users to select the week, here's a template for doing that:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;test_timepicker&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="dropdown" token="week_timepicker"&amp;gt;
      &amp;lt;label&amp;gt;Week&amp;lt;/label&amp;gt;
      &amp;lt;choice value="w1"&amp;gt;Week 1&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="w2"&amp;gt;Week 2&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="w3"&amp;gt;Week 3&amp;lt;/choice&amp;gt;
      &amp;lt;change&amp;gt;
        &amp;lt;condition label="Week 1"&amp;gt;
          &amp;lt;set token="time_earliest"&amp;gt;@y&amp;lt;/set&amp;gt;
          &amp;lt;set token="time_latest"&amp;gt;@y+1w&amp;lt;/set&amp;gt;
        &amp;lt;/condition&amp;gt;
        &amp;lt;condition label="Week 2"&amp;gt;
          &amp;lt;set token="time_earliest"&amp;gt;@y+1w&amp;lt;/set&amp;gt;
          &amp;lt;set token="time_latest"&amp;gt;@y+2w&amp;lt;/set&amp;gt;
        &amp;lt;/condition&amp;gt;
        &amp;lt;condition label="Week 3"&amp;gt;
          &amp;lt;set token="time_earliest"&amp;gt;@y+2w&amp;lt;/set&amp;gt;
          &amp;lt;set token="time_latest"&amp;gt;@y+3w&amp;lt;/set&amp;gt;
        &amp;lt;/condition&amp;gt;
      &amp;lt;/change&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;event&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=_internal&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;$time_earliest$&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;$time_latest$&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
      &amp;lt;/event&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can add to this list of options and make it totally custom - some week options, some day options, etc. The key is to add a &lt;CODE&gt;&amp;lt;choice&amp;gt;&lt;/CODE&gt; relating to the custom time period you want to specify and then add a &lt;CODE&gt;&amp;lt;condition&amp;gt;&lt;/CODE&gt; element below that sets both tokens &lt;CODE&gt;$time_earliest$&lt;/CODE&gt; and &lt;CODE&gt;$time_latest$&lt;/CODE&gt;, which are consumed by the panel below running a search. The values you'll use in the &lt;CODE&gt;&amp;lt;condition&amp;gt;&lt;/CODE&gt; elements will be drawn from this guide: &lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/SearchTimeModifiers"&gt;http://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/SearchTimeModifiers&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Mar 2018 16:35:31 GMT</pubDate>
    <dc:creator>elliotproebstel</dc:creator>
    <dc:date>2018-03-28T16:35:31Z</dc:date>
    <item>
      <title>Filtering with the week number</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Filtering-with-the-week-number/m-p/291776#M55599</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
I have a question: can we do a filtering with the week number&lt;BR /&gt;
In my dashboard I have filtering on the period (yesterday, last week,last month ...), I want to add in this drop-down list the numbers of the weeks to be able to filtering on it&lt;BR /&gt;
example: week 1: from the first of January to 07 January&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 14:07:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Filtering-with-the-week-number/m-p/291776#M55599</guid>
      <dc:creator>taha13</dc:creator>
      <dc:date>2018-03-27T14:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering with the week number</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Filtering-with-the-week-number/m-p/291777#M55600</link>
      <description>&lt;P&gt;Yes, just add some conditional logic like this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval date=strftime(_time,"%d")
| eval week=case(date&amp;gt;0 AND date&amp;lt;8,"week1",date&amp;gt;7 AND date&amp;lt;15,"week2",date&amp;gt;15 AND date&amp;lt;22,"week3",1=1,"week4")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Mar 2018 16:41:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Filtering-with-the-week-number/m-p/291777#M55600</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2018-03-27T16:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering with the week number</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Filtering-with-the-week-number/m-p/291778#M55601</link>
      <description>&lt;P&gt;@taha13 did this work for you?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 13:44:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Filtering-with-the-week-number/m-p/291778#M55601</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2018-03-28T13:44:28Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering with the week number</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Filtering-with-the-week-number/m-p/291779#M55602</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| eval weeknr=strftime(_time,"%V")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or use %U or %W depending on which definition of the week numbering you prefer. See also: &lt;A href="http://php.net/manual/en/function.strftime.php"&gt;http://php.net/manual/en/function.strftime.php&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 14:29:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Filtering-with-the-week-number/m-p/291779#M55602</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-03-28T14:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering with the week number</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Filtering-with-the-week-number/m-p/291780#M55603</link>
      <description>&lt;P&gt;I think I'm reading your question differently than the others who've answered. It looks to me like you want to be able to add some options into the time filter dropdown to allow users to search for events by week number. The good news: this is possible. The bad news: I don't think it's possible to do this by adding to the regular timepicker. But if you want a dashboard where the time filters are done in a custom dropdown that allows users to select the week, here's a template for doing that:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;test_timepicker&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="dropdown" token="week_timepicker"&amp;gt;
      &amp;lt;label&amp;gt;Week&amp;lt;/label&amp;gt;
      &amp;lt;choice value="w1"&amp;gt;Week 1&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="w2"&amp;gt;Week 2&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="w3"&amp;gt;Week 3&amp;lt;/choice&amp;gt;
      &amp;lt;change&amp;gt;
        &amp;lt;condition label="Week 1"&amp;gt;
          &amp;lt;set token="time_earliest"&amp;gt;@y&amp;lt;/set&amp;gt;
          &amp;lt;set token="time_latest"&amp;gt;@y+1w&amp;lt;/set&amp;gt;
        &amp;lt;/condition&amp;gt;
        &amp;lt;condition label="Week 2"&amp;gt;
          &amp;lt;set token="time_earliest"&amp;gt;@y+1w&amp;lt;/set&amp;gt;
          &amp;lt;set token="time_latest"&amp;gt;@y+2w&amp;lt;/set&amp;gt;
        &amp;lt;/condition&amp;gt;
        &amp;lt;condition label="Week 3"&amp;gt;
          &amp;lt;set token="time_earliest"&amp;gt;@y+2w&amp;lt;/set&amp;gt;
          &amp;lt;set token="time_latest"&amp;gt;@y+3w&amp;lt;/set&amp;gt;
        &amp;lt;/condition&amp;gt;
      &amp;lt;/change&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;event&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=_internal&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;$time_earliest$&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;$time_latest$&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
      &amp;lt;/event&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can add to this list of options and make it totally custom - some week options, some day options, etc. The key is to add a &lt;CODE&gt;&amp;lt;choice&amp;gt;&lt;/CODE&gt; relating to the custom time period you want to specify and then add a &lt;CODE&gt;&amp;lt;condition&amp;gt;&lt;/CODE&gt; element below that sets both tokens &lt;CODE&gt;$time_earliest$&lt;/CODE&gt; and &lt;CODE&gt;$time_latest$&lt;/CODE&gt;, which are consumed by the panel below running a search. The values you'll use in the &lt;CODE&gt;&amp;lt;condition&amp;gt;&lt;/CODE&gt; elements will be drawn from this guide: &lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/SearchTimeModifiers"&gt;http://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/SearchTimeModifiers&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 16:35:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Filtering-with-the-week-number/m-p/291780#M55603</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-03-28T16:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering with the week number</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Filtering-with-the-week-number/m-p/291781#M55604</link>
      <description>&lt;P&gt;Just a suggestion - Use &lt;CODE&gt;@y@w&lt;/CODE&gt; to start from the first day of the week&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 17:38:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Filtering-with-the-week-number/m-p/291781#M55604</guid>
      <dc:creator>omerl</dc:creator>
      <dc:date>2018-03-28T17:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering with the week number</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Filtering-with-the-week-number/m-p/291782#M55605</link>
      <description>&lt;P&gt;That will break at week boundaries defined by day of the week, not by Jan1-7, as requested. &lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 19:47:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Filtering-with-the-week-number/m-p/291782#M55605</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-03-28T19:47:29Z</dc:date>
    </item>
  </channel>
</rss>

