<?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 use eval on a token from a time picker and add it to a label for a chart? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-eval-on-a-token-from-a-time-picker-and-add-it-to-a/m-p/279548#M17732</link>
    <description>&lt;P&gt;I know it's been a while, but might help someone else.  Just been wrestling with similar problem.  I've found that evals need to be inside the input block.  Also, when tokens are used there, they need to be in single quotes.  Finally, it's strftime rather than strptime.  Try...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="time" token="InputTime"&amp;gt;
       &amp;lt;label&amp;gt;TimePicker for SourceType&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="new_time"&amp;gt;strftime('InputTime.earliest', "%m/%d/%Y")&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;chart&amp;gt;
         &amp;lt;title&amp;gt;Day 1 - $new_time$&amp;lt;/title&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 26 Feb 2016 12:06:35 GMT</pubDate>
    <dc:creator>JovanMilosevic</dc:creator>
    <dc:date>2016-02-26T12:06:35Z</dc:date>
    <item>
      <title>How to use eval on a token from a time picker and add it to a label for a chart?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-eval-on-a-token-from-a-time-picker-and-add-it-to-a/m-p/279545#M17729</link>
      <description>&lt;P&gt;In my Splunk Dashboard, I have a time picker and charts which shows a search for each subsequent day from the earliest time selected in the time picker.&lt;/P&gt;

&lt;P&gt;I want to display a formatted date in a label for each chart. So for example:&lt;/P&gt;

&lt;P&gt;Day 1 - 15/12/2015&lt;BR /&gt;
Day 2 - 16/12/2015&lt;BR /&gt;
Day 3 - 17/12/2015&lt;BR /&gt;
etc&lt;/P&gt;

&lt;P&gt;I understand that these dates can be derived from the time picker's token. Here is what I have attempted so far just for the first date but it does not seem to work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="time" token="InputTime"&amp;gt;
      &amp;lt;label&amp;gt;TimePicker for SourceType&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;/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;eval token="new_time"&amp;gt;strptime($InputTime.earliest$, "%m/%d/%Y")&amp;lt;/eval&amp;gt;
        &amp;lt;title&amp;gt;Day 1 - $new_time$&amp;lt;/title&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Could anybody tell me what I am doing wrong?&lt;BR /&gt;
Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2015 08:13:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-eval-on-a-token-from-a-time-picker-and-add-it-to-a/m-p/279545#M17729</guid>
      <dc:creator>KevinAdu</dc:creator>
      <dc:date>2015-12-15T08:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval on a token from a time picker and add it to a label for a chart?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-eval-on-a-token-from-a-time-picker-and-add-it-to-a/m-p/279546#M17730</link>
      <description>&lt;P&gt;I'm not sure if you can perform an eval on a time token to convert it to another time format... I know that you can do this though:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;input type="time" token="InputTime"&amp;gt;
       &amp;lt;label&amp;gt;TimePicker for SourceType&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;/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;title&amp;gt;Day 1 - $InputTime.earliest$ to $InputTime.latest$&amp;lt;/title&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Dec 2015 18:30:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-eval-on-a-token-from-a-time-picker-and-add-it-to-a/m-p/279546#M17730</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2015-12-17T18:30:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval on a token from a time picker and add it to a label for a chart?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-eval-on-a-token-from-a-time-picker-and-add-it-to-a/m-p/279547#M17731</link>
      <description>&lt;P&gt;Yeah but the issue is that will show it in the unix timestamp format. So I was hoping I could change it to make it more readable.&lt;/P&gt;

&lt;P&gt;Where I saw the eval command being used that way was on this page:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.2/Viz/tokens"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.2/Viz/tokens&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2015 00:52:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-eval-on-a-token-from-a-time-picker-and-add-it-to-a/m-p/279547#M17731</guid>
      <dc:creator>KevinAdu</dc:creator>
      <dc:date>2015-12-21T00:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval on a token from a time picker and add it to a label for a chart?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-eval-on-a-token-from-a-time-picker-and-add-it-to-a/m-p/279548#M17732</link>
      <description>&lt;P&gt;I know it's been a while, but might help someone else.  Just been wrestling with similar problem.  I've found that evals need to be inside the input block.  Also, when tokens are used there, they need to be in single quotes.  Finally, it's strftime rather than strptime.  Try...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="time" token="InputTime"&amp;gt;
       &amp;lt;label&amp;gt;TimePicker for SourceType&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="new_time"&amp;gt;strftime('InputTime.earliest', "%m/%d/%Y")&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;chart&amp;gt;
         &amp;lt;title&amp;gt;Day 1 - $new_time$&amp;lt;/title&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Feb 2016 12:06:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-eval-on-a-token-from-a-time-picker-and-add-it-to-a/m-p/279548#M17732</guid>
      <dc:creator>JovanMilosevic</dc:creator>
      <dc:date>2016-02-26T12:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval on a token from a time picker and add it to a label for a chart?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-eval-on-a-token-from-a-time-picker-and-add-it-to-a/m-p/279549#M17733</link>
      <description>&lt;P&gt;Hi   JovanMilosevic, did this indeed work for you? We are looking for your secret. (-: Please check question:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/425146/simple-xml-dashboard-eval-strptime-using-old-value.html"&gt;https://answers.splunk.com/answers/425146/simple-xml-dashboard-eval-strptime-using-old-value.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2016 21:49:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-eval-on-a-token-from-a-time-picker-and-add-it-to-a/m-p/279549#M17733</guid>
      <dc:creator>rmarcum</dc:creator>
      <dc:date>2016-07-11T21:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval on a token from a time picker and add it to a label for a chart?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-eval-on-a-token-from-a-time-picker-and-add-it-to-a/m-p/279550#M17734</link>
      <description>&lt;P&gt;Try to insert eval command in the search of a panel and then extract the token in the panel and show it in the panel's title.&lt;BR /&gt;
But if you do this, you have to manage the showed columns to don't see the value in a column: in this case you have to use the &lt;CODE&gt;&amp;lt;fields&amp;gt;&lt;/CODE&gt; option&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2016 08:51:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-eval-on-a-token-from-a-time-picker-and-add-it-to-a/m-p/279550#M17734</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2016-07-12T08:51:29Z</dc:date>
    </item>
  </channel>
</rss>

