<?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: Panel to display n days before data based upon time picker selected in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Panel-to-display-n-days-before-data-based-upon-time-picker/m-p/478694#M45885</link>
    <description>&lt;P&gt;Played with this on Splunk 7.1.x.  I have always created a search, used addinfo to the earliest latest, manipulated them as needed and then created tokens to use elsewhere.  But I like your approach too.  &lt;/P&gt;

&lt;P&gt;Anyway, I removed some quotes and added a check for the case when latest is now...because that didn't seem to work as a modifier in the relative_time() function.  Also, you may need to account for the all time scenario too...&lt;/P&gt;

&lt;P&gt;Here's a very simple dashboard that just shows the tokens in the title of an empty panel.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;Timepicker Test&amp;lt;/label&amp;gt;
  &amp;lt;fieldset&amp;gt;
    &amp;lt;input type="time" token="Time_Range" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;Time&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;
        &amp;lt;earliest&amp;gt;-15m&amp;lt;/earliest&amp;gt;
        &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
      &amp;lt;/default&amp;gt;
      &amp;lt;change&amp;gt;
        &amp;lt;eval token="weekearliest"&amp;gt;relative_time(relative_time(now(),$earliest$,-7d)&amp;lt;/eval&amp;gt;
        &amp;lt;eval token="weeklatest"&amp;gt;if($latest$="now",now(),relative_time(now(),$latest$)&amp;lt;/eval&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;title&amp;gt;$weekearliest$   $weeklatest$&amp;lt;/title&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query/&amp;gt;
        &amp;lt;/search&amp;gt;
      &amp;lt;/single&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>Sun, 15 Sep 2019 12:58:59 GMT</pubDate>
    <dc:creator>maciep</dc:creator>
    <dc:date>2019-09-15T12:58:59Z</dc:date>
    <item>
      <title>Panel to display n days before data based upon time picker selected</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Panel-to-display-n-days-before-data-based-upon-time-picker/m-p/478692#M45883</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;Am trying to have two panels with one showing the data corresponding to the range selected in time picker and the other panel showing data for the same time range but 7 days earlier. Have tried using eval to assign the 7d time range into tokens (after searching online).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    &amp;lt;input type="time" token="Time_Range" &amp;gt;
      &amp;lt;label&amp;gt;Time&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;
        &amp;lt;earliest&amp;gt;-15m&amp;lt;/earliest&amp;gt;
        &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
      &amp;lt;/default&amp;gt;
      &amp;lt;change&amp;gt;
        &amp;lt;eval token="weekearliest"&amp;gt;relative_time(relative_time(time(), "$earliest$"), "-7d")&amp;lt;/eval&amp;gt;
        &amp;lt;eval token="weeklatest"&amp;gt;relative_time(relative_time(time(), "$latest$"), "-7d")&amp;lt;/eval&amp;gt;
      &amp;lt;/change&amp;gt;
    &amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Have added the tokens initialized weekearliest and weeklatest as token based search in another panel but it doesnt seems to work, &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;          &amp;lt;earliest&amp;gt;$weekearliest$&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;$weeklatest$&amp;lt;/latest&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can kindly provide pointers to check on how to implement them?&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2019 04:27:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Panel-to-display-n-days-before-data-based-upon-time-picker/m-p/478692#M45883</guid>
      <dc:creator>irvanramuk</dc:creator>
      <dc:date>2019-09-10T04:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: Panel to display n days before data based upon time picker selected</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Panel-to-display-n-days-before-data-based-upon-time-picker/m-p/478693#M45884</link>
      <description>&lt;P&gt;your token is time_range, so your evals on change tags should look something like this &lt;CODE&gt;relative_time(relative_time(time_range, "$earliest$"), "-7d")&lt;BR /&gt;
         &amp;lt;eval token="weeklatest"&amp;gt;relative_time(relative_time(time_range, "$latest$"), "-7d")&amp;lt;/eval&amp;gt;&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:09:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Panel-to-display-n-days-before-data-based-upon-time-picker/m-p/478693#M45884</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2020-09-30T02:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: Panel to display n days before data based upon time picker selected</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Panel-to-display-n-days-before-data-based-upon-time-picker/m-p/478694#M45885</link>
      <description>&lt;P&gt;Played with this on Splunk 7.1.x.  I have always created a search, used addinfo to the earliest latest, manipulated them as needed and then created tokens to use elsewhere.  But I like your approach too.  &lt;/P&gt;

&lt;P&gt;Anyway, I removed some quotes and added a check for the case when latest is now...because that didn't seem to work as a modifier in the relative_time() function.  Also, you may need to account for the all time scenario too...&lt;/P&gt;

&lt;P&gt;Here's a very simple dashboard that just shows the tokens in the title of an empty panel.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;Timepicker Test&amp;lt;/label&amp;gt;
  &amp;lt;fieldset&amp;gt;
    &amp;lt;input type="time" token="Time_Range" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;Time&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;
        &amp;lt;earliest&amp;gt;-15m&amp;lt;/earliest&amp;gt;
        &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
      &amp;lt;/default&amp;gt;
      &amp;lt;change&amp;gt;
        &amp;lt;eval token="weekearliest"&amp;gt;relative_time(relative_time(now(),$earliest$,-7d)&amp;lt;/eval&amp;gt;
        &amp;lt;eval token="weeklatest"&amp;gt;if($latest$="now",now(),relative_time(now(),$latest$)&amp;lt;/eval&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;title&amp;gt;$weekearliest$   $weeklatest$&amp;lt;/title&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query/&amp;gt;
        &amp;lt;/search&amp;gt;
      &amp;lt;/single&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>Sun, 15 Sep 2019 12:58:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Panel-to-display-n-days-before-data-based-upon-time-picker/m-p/478694#M45885</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2019-09-15T12:58:59Z</dc:date>
    </item>
  </channel>
</rss>

