<?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 How do you make a search that would return  timerange depending on dropdown values? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-make-a-search-that-would-return-timerange-depending/m-p/454735#M29815</link>
    <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;

&lt;P&gt;I have a dashboard with 2 dropdown filters, &lt;STRONG&gt;&lt;EM&gt;From Date&lt;/EM&gt;&lt;/STRONG&gt; and &lt;STRONG&gt;&lt;EM&gt;To Date&lt;/EM&gt;&lt;/STRONG&gt;. Below this is a table. It looks something like the image below:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/5752iD365DB50B562C87A/image-size/large?v=v2&amp;amp;px=999" title="alt text" alt="alt text" /&gt;&lt;/span&gt; &lt;/P&gt;

&lt;P&gt;Now, what should happen is that when both of the dropdowns are set to the date today, the search should return results from "date today" and "the last 30 mins". Then, if the dropdown is set to a different date, (for example FROM DATE=9/9/2018, TO DATE=9/11/2018), the search should return results from 9//9/2018 to 9/11/2018.&lt;/P&gt;

&lt;P&gt;What could be the possible solution for this? I am trying to use &lt;CODE&gt;|where&lt;/CODE&gt; and &lt;CODE&gt;|eval&lt;/CODE&gt; but I still can't figure out how to do this.&lt;/P&gt;

&lt;P&gt;I hope anyone can help me solve this.&lt;/P&gt;

&lt;P&gt;Thanks in advance!&lt;/P&gt;

&lt;P&gt;Have a nice day. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 12 Sep 2018 06:03:39 GMT</pubDate>
    <dc:creator>jvmerilla</dc:creator>
    <dc:date>2018-09-12T06:03:39Z</dc:date>
    <item>
      <title>How do you make a search that would return  timerange depending on dropdown values?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-make-a-search-that-would-return-timerange-depending/m-p/454735#M29815</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;

&lt;P&gt;I have a dashboard with 2 dropdown filters, &lt;STRONG&gt;&lt;EM&gt;From Date&lt;/EM&gt;&lt;/STRONG&gt; and &lt;STRONG&gt;&lt;EM&gt;To Date&lt;/EM&gt;&lt;/STRONG&gt;. Below this is a table. It looks something like the image below:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/5752iD365DB50B562C87A/image-size/large?v=v2&amp;amp;px=999" title="alt text" alt="alt text" /&gt;&lt;/span&gt; &lt;/P&gt;

&lt;P&gt;Now, what should happen is that when both of the dropdowns are set to the date today, the search should return results from "date today" and "the last 30 mins". Then, if the dropdown is set to a different date, (for example FROM DATE=9/9/2018, TO DATE=9/11/2018), the search should return results from 9//9/2018 to 9/11/2018.&lt;/P&gt;

&lt;P&gt;What could be the possible solution for this? I am trying to use &lt;CODE&gt;|where&lt;/CODE&gt; and &lt;CODE&gt;|eval&lt;/CODE&gt; but I still can't figure out how to do this.&lt;/P&gt;

&lt;P&gt;I hope anyone can help me solve this.&lt;/P&gt;

&lt;P&gt;Thanks in advance!&lt;/P&gt;

&lt;P&gt;Have a nice day. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Sep 2018 06:03:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-make-a-search-that-would-return-timerange-depending/m-p/454735#M29815</guid>
      <dc:creator>jvmerilla</dc:creator>
      <dc:date>2018-09-12T06:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do you make a search that would return  timerange depending on dropdown values?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-make-a-search-that-would-return-timerange-depending/m-p/454736#M29816</link>
      <description>&lt;P&gt;in the drop down set the token for earliest and latest.&lt;/P&gt;

&lt;P&gt;In the search query add the below line&lt;/P&gt;

&lt;P&gt;| eval earliest=case(isnum(earliest),earliest,earliest=="-1d","-30m",1=1)&lt;/P&gt;</description>
      <pubDate>Wed, 12 Sep 2018 07:41:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-make-a-search-that-would-return-timerange-depending/m-p/454736#M29816</guid>
      <dc:creator>SathyaNarayanan</dc:creator>
      <dc:date>2018-09-12T07:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do you make a search that would return  timerange depending on dropdown values?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-make-a-search-that-would-return-timerange-depending/m-p/454737#M29817</link>
      <description>&lt;P&gt;@jvmerilla ,&lt;/P&gt;

&lt;P&gt;Try this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;Time Token&amp;lt;/label&amp;gt;
  &amp;lt;search&amp;gt;
    &amp;lt;query&amp;gt;|makeresults|eval earliest=if("$from$"=="$to$","-30m",strptime("$from$","%m/%d/%Y"))|eval latest=if("$from$"=="$to$",now(),strptime("$to$","%m/%d/%Y"))|fields earliest,latest&amp;lt;/query&amp;gt;
    &amp;lt;done&amp;gt;
      &amp;lt;set token="earliest_time"&amp;gt;$result.earliest$&amp;lt;/set&amp;gt;
      &amp;lt;set token="latest_time"&amp;gt;$result.latest$&amp;lt;/set&amp;gt;
    &amp;lt;/done&amp;gt;
  &amp;lt;/search&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="dropdown" token="from" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;FROM&amp;lt;/label&amp;gt;
      &amp;lt;choice value="9/9/2018"&amp;gt;9/9/2018&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="9/10/2018"&amp;gt;9/10/2018&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="911/2018"&amp;gt;9/11/2018&amp;lt;/choice&amp;gt;
      &amp;lt;default&amp;gt;9/9/2018&amp;lt;/default&amp;gt;
    &amp;lt;/input&amp;gt;
    &amp;lt;input type="dropdown" token="to" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;TO&amp;lt;/label&amp;gt;
      &amp;lt;choice value="9/9/2018"&amp;gt;9/9/2018&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="9/10/2018"&amp;gt;9/10/2018&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="911/2018"&amp;gt;9/11/2018&amp;lt;/choice&amp;gt;
      &amp;lt;default&amp;gt;9/10/2018&amp;lt;/default&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;chart&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=_internal|timechart span=10m count by sourcetype&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;$earliest_time$&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;$latest_time$&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="charting.chart"&amp;gt;line&amp;lt;/option&amp;gt;
        &amp;lt;option name="charting.drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
      &amp;lt;/chart&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Sep 2018 07:55:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-make-a-search-that-would-return-timerange-depending/m-p/454737#M29817</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-09-12T07:55:10Z</dc:date>
    </item>
  </channel>
</rss>

