<?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 add / subtract time for a chart panel from the selected time picker value on a dashboard? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-subtract-time-for-a-chart-panel-from-the-selected/m-p/265319#M16688</link>
    <description>&lt;P&gt;Hi Martin, &lt;BR /&gt;
coming back to this one after a lot of time. &lt;BR /&gt;
We are on 6.6. at the moment and I tried your suggestions, here's the first part of the dashboard: &lt;/P&gt;

&lt;P&gt;CPS_impact_assessment&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="time" token="incTime" searchWhenChanged="false"&amp;gt;
  &amp;lt;label&amp;gt;Incident time&amp;lt;/label&amp;gt;
  &amp;lt;default&amp;gt;
    &amp;lt;earliest&amp;gt;-60m@m&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="1weekearliest"&amp;gt;relative_time($incTime.earliest$, "-7d")&amp;lt;/eval&amp;gt;
    &amp;lt;eval token="1weeklatest"&amp;gt;relative_time($incTime.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;...&lt;/P&gt;

&lt;P&gt;further down I am using $1weekearliest$ and $1weeklatest$ as the time token for a panel but the panel seems to show "all time" &lt;BR /&gt;
I am also displaying the tokens in the panel title but they both appear as &lt;STRONG&gt;NaN&lt;/STRONG&gt;. &lt;BR /&gt;
What have I done wrong? &lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 21:41:10 GMT</pubDate>
    <dc:creator>mraudaschl</dc:creator>
    <dc:date>2020-09-29T21:41:10Z</dc:date>
    <item>
      <title>How to add / subtract time for a chart panel from the selected time picker value on a dashboard?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-subtract-time-for-a-chart-panel-from-the-selected/m-p/265309#M16678</link>
      <description>&lt;P&gt;I want to create a dashboard with two panels and a timepicker. One panel needs to show a chart according to the timepicker selection of the user and another panel with exactly the same data, but one week before. I tried substracting &lt;CODE&gt;-7d&lt;/CODE&gt; from the timepicker tokens, but didn't succeed. After searching Splunk Answers, I came up with below, but now I am getting: &lt;CODE&gt;Error in 'eval' command: The expression is malformed. Expected )&lt;/CODE&gt;, ut there are not brackets missing, so I tried adding quotes to the timepicker tokens, without success (no results are shown). &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main source=X_monitor sourcetype=X_monitor 
earliest=[|gentimes start=-1 | eval t=relative_time($field1.earliest$,"-7d") | return $t]
latest=[|gentimes start=-1 | eval t=relative_time($field1.latest$,"-7d") | return $t]
|timechart count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;field1 is my shared timepicker&lt;/P&gt;

&lt;P&gt;Any suggestions would be appreciated. &lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2016 12:11:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-subtract-time-for-a-chart-panel-from-the-selected/m-p/265309#M16678</guid>
      <dc:creator>mraudaschl</dc:creator>
      <dc:date>2016-05-20T12:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to add / subtract time for a chart panel from the selected time picker value on a dashboard?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-subtract-time-for-a-chart-panel-from-the-selected/m-p/265310#M16679</link>
      <description>&lt;P&gt;Assuming you're on 6.4, you can use the eval element in Simple XML: &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.1/Viz/PanelreferenceforSimplifiedXML#eval"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.1/Viz/PanelreferenceforSimplifiedXML#eval&lt;/A&gt;&lt;BR /&gt;
Using that you can set a second token to something like &lt;CODE&gt;relative_time($field1.earliest$, "-7d")&lt;/CODE&gt; and use that second token in your search. Make sure you cover all cases your time range picker can return.&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2016 12:40:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-subtract-time-for-a-chart-panel-from-the-selected/m-p/265310#M16679</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2016-05-20T12:40:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to add / subtract time for a chart panel from the selected time picker value on a dashboard?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-subtract-time-for-a-chart-panel-from-the-selected/m-p/265311#M16680</link>
      <description>&lt;P&gt;we are on 6.2.4, does anyone have any other suggestion?&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2016 13:59:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-subtract-time-for-a-chart-panel-from-the-selected/m-p/265311#M16680</guid>
      <dc:creator>mraudaschl</dc:creator>
      <dc:date>2016-05-20T13:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to add / subtract time for a chart panel from the selected time picker value on a dashboard?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-subtract-time-for-a-chart-panel-from-the-selected/m-p/265312#M16681</link>
      <description>&lt;P&gt;Try like this for your second search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main source=X_monitor sourcetype=X_monitor [|gentimes start=-1 | addinfo | eval earliest=relative_time(info_min_time,"-7d") | eval latest=relative_time(info_max_time,"-7d") | table earliest latest | format "" "" "" "" "" ""]
|timechart count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;More information on addinfo command here: &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.4/SearchReference/Addinfo"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.4/SearchReference/Addinfo&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2016 14:18:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-subtract-time-for-a-chart-panel-from-the-selected/m-p/265312#M16681</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-05-20T14:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to add / subtract time for a chart panel from the selected time picker value on a dashboard?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-subtract-time-for-a-chart-panel-from-the-selected/m-p/265313#M16682</link>
      <description>&lt;P&gt;Upgrade to 6.4, many great things await - bugfixes, security patches, performance improvements, new features... there isn't any real reason not to upgrade.&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2016 14:35:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-subtract-time-for-a-chart-panel-from-the-selected/m-p/265313#M16682</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2016-05-20T14:35:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to add / subtract time for a chart panel from the selected time picker value on a dashboard?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-subtract-time-for-a-chart-panel-from-the-selected/m-p/265314#M16683</link>
      <description>&lt;P&gt;Thanks Somesoni2, this works like a charm for me. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 May 2016 13:45:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-subtract-time-for-a-chart-panel-from-the-selected/m-p/265314#M16683</guid>
      <dc:creator>mraudaschl</dc:creator>
      <dc:date>2016-05-30T13:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to add / subtract time for a chart panel from the selected time picker value on a dashboard?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-subtract-time-for-a-chart-panel-from-the-selected/m-p/265315#M16684</link>
      <description>&lt;P&gt;This does not work for me, the gentimes  just gives zero results. Anything I am missing ? Please help ! Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Sep 2017 21:53:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-subtract-time-for-a-chart-panel-from-the-selected/m-p/265315#M16684</guid>
      <dc:creator>splunkannm</dc:creator>
      <dc:date>2017-09-14T21:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to add / subtract time for a chart panel from the selected time picker value on a dashboard?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-subtract-time-for-a-chart-panel-from-the-selected/m-p/265316#M16685</link>
      <description>&lt;P&gt;What's your full query? The gentimes here is just to generate a sample row without hitting any of the indexes. If you're using 6.3+, you can use &lt;CODE&gt;| makeresults&lt;/CODE&gt; instead of &lt;CODE&gt;| gentimes start=-1&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Sep 2017 22:06:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-subtract-time-for-a-chart-panel-from-the-selected/m-p/265316#M16685</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-09-14T22:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to add / subtract time for a chart panel from the selected time picker value on a dashboard?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-subtract-time-for-a-chart-panel-from-the-selected/m-p/265317#M16686</link>
      <description>&lt;P&gt;index="card_iss" sourcetype="global_volume" &lt;BR /&gt;
 [|makeresults start=-1 | addinfo | eval earliest=relative_time(info_min_time,"-7d") | eval latest=relative_time(info_max_time,"-7d") | table earliest latest | format "" "" "" "" "" ""]&lt;BR /&gt;
 |rename a as b&lt;BR /&gt;
|............&lt;BR /&gt;
|..........&lt;BR /&gt;
|geom a b c&lt;BR /&gt;
|fields + a b c&lt;/P&gt;

&lt;P&gt;Note makeresults and gentimes both yielded no results..&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:47:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-subtract-time-for-a-chart-panel-from-the-selected/m-p/265317#M16686</guid>
      <dc:creator>splunkannm</dc:creator>
      <dc:date>2020-09-29T15:47:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to add / subtract time for a chart panel from the selected time picker value on a dashboard?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-subtract-time-for-a-chart-panel-from-the-selected/m-p/265318#M16687</link>
      <description>&lt;P&gt;Note I removed the start=-1 in the search..&lt;/P&gt;</description>
      <pubDate>Thu, 14 Sep 2017 23:05:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-subtract-time-for-a-chart-panel-from-the-selected/m-p/265318#M16687</guid>
      <dc:creator>splunkannm</dc:creator>
      <dc:date>2017-09-14T23:05:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to add / subtract time for a chart panel from the selected time picker value on a dashboard?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-subtract-time-for-a-chart-panel-from-the-selected/m-p/265319#M16688</link>
      <description>&lt;P&gt;Hi Martin, &lt;BR /&gt;
coming back to this one after a lot of time. &lt;BR /&gt;
We are on 6.6. at the moment and I tried your suggestions, here's the first part of the dashboard: &lt;/P&gt;

&lt;P&gt;CPS_impact_assessment&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="time" token="incTime" searchWhenChanged="false"&amp;gt;
  &amp;lt;label&amp;gt;Incident time&amp;lt;/label&amp;gt;
  &amp;lt;default&amp;gt;
    &amp;lt;earliest&amp;gt;-60m@m&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="1weekearliest"&amp;gt;relative_time($incTime.earliest$, "-7d")&amp;lt;/eval&amp;gt;
    &amp;lt;eval token="1weeklatest"&amp;gt;relative_time($incTime.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;...&lt;/P&gt;

&lt;P&gt;further down I am using $1weekearliest$ and $1weeklatest$ as the time token for a panel but the panel seems to show "all time" &lt;BR /&gt;
I am also displaying the tokens in the panel title but they both appear as &lt;STRONG&gt;NaN&lt;/STRONG&gt;. &lt;BR /&gt;
What have I done wrong? &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:41:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-subtract-time-for-a-chart-panel-from-the-selected/m-p/265319#M16688</guid>
      <dc:creator>mraudaschl</dc:creator>
      <dc:date>2020-09-29T21:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to add / subtract time for a chart panel from the selected time picker value on a dashboard?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-subtract-time-for-a-chart-panel-from-the-selected/m-p/265320#M16689</link>
      <description>&lt;P&gt;Two things. First, apparently you need &lt;CODE&gt;$earliest$&lt;/CODE&gt; instead of &lt;CODE&gt;$field.earliest$&lt;/CODE&gt; - the former gets you the value that is about to change, the latter will get you the old value.&lt;/P&gt;

&lt;P&gt;Second and more importantly, relative_time expects an epoch as its first parameter. It'll work if you define specific points in time, it won't work if you define relative time strings. For those you'd have to do something like &lt;CODE&gt;relative_time(relative_time(time(), "$earliest$"), "-7d")&lt;/CODE&gt;... handling all the options can be tricky. You can get epoch numbers for points in time, relative time strings, "now", null, 0, "rt-30m", "rt", maybe more.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:38:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-subtract-time-for-a-chart-panel-from-the-selected/m-p/265320#M16689</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2020-09-29T21:38:01Z</dc:date>
    </item>
  </channel>
</rss>

