<?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 Manipulating time token with a comparison in dashboard in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Manipulating-time-token-with-a-comparison-in-dashboard/m-p/555948#M38642</link>
    <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I'm quite new to Splunk so sorry in advance if I'm asking a silly question.&lt;BR /&gt;I'm trying to modify token selected by user with time picker earliest / latest to have -5 days / +5 days that I'm then using in epoch format in my search combined with info-min-time / info_max_time.&lt;/P&gt;&lt;P&gt;So far, following other topics and knowledge base I've been able to get it down, except when the user selects "All time" in time picker which ends up having a earliest token with a negative value.&lt;/P&gt;&lt;P&gt;I'm doing the following at the beginning of my dashboard and then using TimeRange.earliest_epoch / TimeRange.latest_epoch in my panels.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; &amp;lt;input type="time" token="TimeRange"&amp;gt;
      &amp;lt;label&amp;gt;TimeRange&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;
        &amp;lt;earliest&amp;gt;0&amp;lt;/earliest&amp;gt;
        &amp;lt;latest&amp;gt;&amp;lt;/latest&amp;gt;
      &amp;lt;/default&amp;gt;
      &amp;lt;change&amp;gt;
        &amp;lt;eval token="TimeRange.earliest_epoch"&amp;gt;if(isnum('earliest'),'earliest',relative_time(now(),'earliest')-432000&amp;lt;/eval&amp;gt;
                &amp;lt;eval token="TimeRange.latest_epoch"&amp;gt;if(isnum('latest'),'latest',relative_time(now(),'latest')+432000&amp;lt;/eval&amp;gt;
      &amp;lt;/change&amp;gt;
    &amp;lt;/input&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I added a table panel to display the values of the tokens to see what's happening exactly :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;title&amp;gt;testDates&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults 
| eval StartTimestamp0="$TimeRange.earliest$"
| eval StartTimestamp1=$TimeRange.earliest_epoch$
| eval starttime=strftime(StartTimestamp1,"%Y-%m-%d %H:%M:%S.%Q")&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;$TimeRange.earliest$&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;$TimeRange.latest$&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No surprise, when selecting "All time" it gave me :&lt;/P&gt;&lt;P&gt;StartTimestamp0 = 0&lt;/P&gt;&lt;P&gt;StartTimestamp1 = -432000&lt;/P&gt;&lt;P&gt;Which is making my subsequent searchs in panels to fail.&lt;/P&gt;&lt;P&gt;I don't manage to catch the case where earliest = 0 before assigning value to TimeRange.earliest_epoch or check if second token equals -432000 to assign a different value (1514764800 in this case as this is a safe old date for my dataset).&lt;/P&gt;&lt;P&gt;All my attempts failed, such as adding a second token where I checked if equal&amp;nbsp; -432000 or below 0&amp;nbsp; :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;        &amp;lt;eval token="TimeRange.earliest_epoch2"&amp;gt;if('TimeRange.earliest_epoch'=='-432000','1514764800','TimeRange.earliest_epoch')&amp;lt;/eval&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;or&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;eval token="TimeRange.earliest_epoch2"&amp;gt;if('TimeRange.earliest_epoch'&amp;amp;lt;'0','1514764800','TimeRange.earliest_epoch')&amp;lt;/eval&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The second token kept the value of TimeRange.earliest_epoch. I added an imbricated if condition in the first token eval and again it looks like it goes to else case everytime.&lt;/P&gt;&lt;P&gt;Can you please help me understand what is failing ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance !&lt;/P&gt;</description>
    <pubDate>Wed, 16 Jun 2021 10:16:21 GMT</pubDate>
    <dc:creator>Shahindoh</dc:creator>
    <dc:date>2021-06-16T10:16:21Z</dc:date>
    <item>
      <title>Manipulating time token with a comparison in dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Manipulating-time-token-with-a-comparison-in-dashboard/m-p/555948#M38642</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I'm quite new to Splunk so sorry in advance if I'm asking a silly question.&lt;BR /&gt;I'm trying to modify token selected by user with time picker earliest / latest to have -5 days / +5 days that I'm then using in epoch format in my search combined with info-min-time / info_max_time.&lt;/P&gt;&lt;P&gt;So far, following other topics and knowledge base I've been able to get it down, except when the user selects "All time" in time picker which ends up having a earliest token with a negative value.&lt;/P&gt;&lt;P&gt;I'm doing the following at the beginning of my dashboard and then using TimeRange.earliest_epoch / TimeRange.latest_epoch in my panels.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; &amp;lt;input type="time" token="TimeRange"&amp;gt;
      &amp;lt;label&amp;gt;TimeRange&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;
        &amp;lt;earliest&amp;gt;0&amp;lt;/earliest&amp;gt;
        &amp;lt;latest&amp;gt;&amp;lt;/latest&amp;gt;
      &amp;lt;/default&amp;gt;
      &amp;lt;change&amp;gt;
        &amp;lt;eval token="TimeRange.earliest_epoch"&amp;gt;if(isnum('earliest'),'earliest',relative_time(now(),'earliest')-432000&amp;lt;/eval&amp;gt;
                &amp;lt;eval token="TimeRange.latest_epoch"&amp;gt;if(isnum('latest'),'latest',relative_time(now(),'latest')+432000&amp;lt;/eval&amp;gt;
      &amp;lt;/change&amp;gt;
    &amp;lt;/input&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I added a table panel to display the values of the tokens to see what's happening exactly :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;title&amp;gt;testDates&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults 
| eval StartTimestamp0="$TimeRange.earliest$"
| eval StartTimestamp1=$TimeRange.earliest_epoch$
| eval starttime=strftime(StartTimestamp1,"%Y-%m-%d %H:%M:%S.%Q")&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;$TimeRange.earliest$&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;$TimeRange.latest$&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No surprise, when selecting "All time" it gave me :&lt;/P&gt;&lt;P&gt;StartTimestamp0 = 0&lt;/P&gt;&lt;P&gt;StartTimestamp1 = -432000&lt;/P&gt;&lt;P&gt;Which is making my subsequent searchs in panels to fail.&lt;/P&gt;&lt;P&gt;I don't manage to catch the case where earliest = 0 before assigning value to TimeRange.earliest_epoch or check if second token equals -432000 to assign a different value (1514764800 in this case as this is a safe old date for my dataset).&lt;/P&gt;&lt;P&gt;All my attempts failed, such as adding a second token where I checked if equal&amp;nbsp; -432000 or below 0&amp;nbsp; :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;        &amp;lt;eval token="TimeRange.earliest_epoch2"&amp;gt;if('TimeRange.earliest_epoch'=='-432000','1514764800','TimeRange.earliest_epoch')&amp;lt;/eval&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;or&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;eval token="TimeRange.earliest_epoch2"&amp;gt;if('TimeRange.earliest_epoch'&amp;amp;lt;'0','1514764800','TimeRange.earliest_epoch')&amp;lt;/eval&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The second token kept the value of TimeRange.earliest_epoch. I added an imbricated if condition in the first token eval and again it looks like it goes to else case everytime.&lt;/P&gt;&lt;P&gt;Can you please help me understand what is failing ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance !&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 10:16:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Manipulating-time-token-with-a-comparison-in-dashboard/m-p/555948#M38642</guid>
      <dc:creator>Shahindoh</dc:creator>
      <dc:date>2021-06-16T10:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulating time token with a comparison in dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Manipulating-time-token-with-a-comparison-in-dashboard/m-p/555959#M38643</link>
      <description>&lt;P&gt;A second token shouldn't be needed.&amp;nbsp; Just use max to keep the token from getting a negative value.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;eval token="TimeRange.earliest_epoch"&amp;gt;max(0,if(isnum('earliest'),'earliest',relative_time(now(),'earliest')-432000)&amp;lt;/eval&amp;gt;&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 16 Jun 2021 12:00:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Manipulating-time-token-with-a-comparison-in-dashboard/m-p/555959#M38643</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-06-16T12:00:32Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulating time token with a comparison in dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Manipulating-time-token-with-a-comparison-in-dashboard/m-p/556005#M38650</link>
      <description>&lt;P&gt;Thank you so much !&amp;nbsp;&lt;/P&gt;&lt;P&gt;Quite simple and elegant and it gave me headaches for 2 days&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Any idea why I couldn't make some simple numeric comparison / evaluation in my XML ?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 15:08:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Manipulating-time-token-with-a-comparison-in-dashboard/m-p/556005#M38650</guid>
      <dc:creator>Shahindoh</dc:creator>
      <dc:date>2021-06-16T15:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulating time token with a comparison in dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Manipulating-time-token-with-a-comparison-in-dashboard/m-p/556015#M38651</link>
      <description>&lt;P&gt;TBH, I didn't really look once I though of a solution.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 15:50:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Manipulating-time-token-with-a-comparison-in-dashboard/m-p/556015#M38651</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-06-16T15:50:26Z</dc:date>
    </item>
  </channel>
</rss>

