<?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: Two different earliest values on one dashboard in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Two-different-earliest-values-on-one-dashboard/m-p/581401#M47640</link>
    <description>&lt;P&gt;Ok, it looks like this works for date ranges.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[stats count | eval early="$timePicker.earliest$" | eval earliest=early-604800 | fields earliest] latest=$timePicker.latest$&lt;/LI-CODE&gt;&lt;P&gt;But if I use presets like Today or Yesterday it doesn't work. Thoughts on this?&lt;/P&gt;</description>
    <pubDate>Mon, 17 Jan 2022 22:29:04 GMT</pubDate>
    <dc:creator>dstuder</dc:creator>
    <dc:date>2022-01-17T22:29:04Z</dc:date>
    <item>
      <title>Two different earliest values on one dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Two-different-earliest-values-on-one-dashboard/m-p/581377#M47638</link>
      <description>&lt;P&gt;I have a time picker on my dashboard called timePicker. There are some pie charts that are populated based on the earliest and latest of the time picker. That part works great.&lt;/P&gt;&lt;P&gt;However, I have on the same dashboard a line graph that shows counts over hour by day for the last 7 days. That earliest and latest is set static like this ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;earliest=-7D@d latest=now&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ideally I would like the line graph to not just show the previous seven days before now, but the previous seven days based on the time picker. The latest part is easy. I could do this ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;earliest=-7D@d latest=$timePicker.latest$&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My trouble is with earliest. I need to subtract&amp;nbsp;604800 from&amp;nbsp; it (seven days worth of seconds). I tried this, but it doesn't seem to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[stats count | eval early=$$timePicker.earliest$$ | eval earliest=early-604800 | fields earliest] latest=$timePicker.latest$&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I doubled $ for the earliest token to escape it out because it is used in a dashobard ... I read somewhere that&amp;nbsp; $ needs to be escaped. Anyway, I get no results. I'm sure my syntax is wrong or maybe I'm going about it wrong. Anyone have any thoughts on how to do this? I guess another thought would be to create a token when the time picker is selected that calculates&amp;nbsp;$timePicker.earliest$ - 604800 but I'm not sure if that is possible or how to do it. Any help would be much appreciated. Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jan 2022 19:04:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Two-different-earliest-values-on-one-dashboard/m-p/581377#M47638</guid>
      <dc:creator>dstuder</dc:creator>
      <dc:date>2022-01-17T19:04:14Z</dc:date>
    </item>
    <item>
      <title>Re: Two different earliest values on one dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Two-different-earliest-values-on-one-dashboard/m-p/581401#M47640</link>
      <description>&lt;P&gt;Ok, it looks like this works for date ranges.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[stats count | eval early="$timePicker.earliest$" | eval earliest=early-604800 | fields earliest] latest=$timePicker.latest$&lt;/LI-CODE&gt;&lt;P&gt;But if I use presets like Today or Yesterday it doesn't work. Thoughts on this?&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jan 2022 22:29:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Two-different-earliest-values-on-one-dashboard/m-p/581401#M47640</guid>
      <dc:creator>dstuder</dc:creator>
      <dc:date>2022-01-17T22:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: Two different earliest values on one dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Two-different-earliest-values-on-one-dashboard/m-p/581402#M47641</link>
      <description>&lt;P class="lia-align-justify"&gt;I think I got it working. I can test if the earliest value is numeric. If it is I can use that, but if it is a relative date I can convert it to epoch format using the relative_time() function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[stats count | eval early="$timePicker.earliest$" | eval epoch=if(isnum(early), early, relative_time(now(), early)) | eval earliest=epoch-604800 | fields earliest] latest=$timePicker.latest$&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jan 2022 23:56:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Two-different-earliest-values-on-one-dashboard/m-p/581402#M47641</guid>
      <dc:creator>dstuder</dc:creator>
      <dc:date>2022-01-17T23:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: Two different earliest values on one dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Two-different-earliest-values-on-one-dashboard/m-p/581409#M47642</link>
      <description>&lt;P&gt;A typical way to do this is to have a hidden search (in this example I put it in a visible panel) that will do calculations based on the timepicker value - as you can see from the search it uses addinfo command to get the info_min_time and info_max_time values and then makes tokens based on those so it handles the case where someone creates a strange time range in the picker.&lt;/P&gt;&lt;P&gt;Save this example as a dashboard and you can see that whatever you select in the time picker, the timechart will show a week prior to that also.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;Time Picker&amp;lt;/label&amp;gt;
  &amp;lt;init&amp;gt;
    &amp;lt;set token="earliest"&amp;gt;-24h&amp;lt;/set&amp;gt;
    &amp;lt;set token="latest"&amp;gt;now&amp;lt;/set&amp;gt;
  &amp;lt;/init&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="time" token="TimePicker"&amp;gt;
      &amp;lt;label&amp;gt;&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;
        &amp;lt;earliest&amp;gt;-24h@h&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;title&amp;gt;Simple pie covering $pie_range$&amp;lt;/title&amp;gt;
      &amp;lt;chart&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=_audit
| stats count by user&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;$TimePicker.earliest$&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;$TimePicker.latest$&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="charting.chart"&amp;gt;pie&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;panel&amp;gt;
      &amp;lt;title&amp;gt;Simple timechart covering $tc_range$&amp;lt;/title&amp;gt;
      &amp;lt;chart&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=_audit
| timechart span=1d count by user&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;$earliest$&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;$TimePicker.latest$&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&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;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
      &amp;lt;/chart&amp;gt;
    &amp;lt;/panel&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;Calculation panel that determines 7 days prior to TimePicker value&amp;lt;/title&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;done&amp;gt;
            &amp;lt;set token="earliest"&amp;gt;$result.earliest$&amp;lt;/set&amp;gt;
            &amp;lt;set token="pie_range"&amp;gt;$result.PieRange$&amp;lt;/set&amp;gt;
            &amp;lt;set token="tc_range"&amp;gt;$result.TCRange$&amp;lt;/set&amp;gt;
          &amp;lt;/done&amp;gt;
          &amp;lt;query&amp;gt;| makeresults
| addinfo
| eval earliest=info_min_time - 604800
| eval PieRange=strftime(info_min_time, "%F %T")."-".strftime(info_max_time, "%F %T")
| eval TCRange=strftime(earliest, "%F %T")."-".strftime(info_max_time, "%F %T")
| table earliest PieRange TCRange&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;$TimePicker.earliest$&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;$TimePicker.latest$&amp;lt;/latest&amp;gt;
        &amp;lt;/search&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;
&amp;lt;/form&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jan 2022 00:09:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Two-different-earliest-values-on-one-dashboard/m-p/581409#M47642</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-01-18T00:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: Two different earliest values on one dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Two-different-earliest-values-on-one-dashboard/m-p/581423#M47643</link>
      <description>&lt;P&gt;You could set additional tokens in the timepicker change handler - see this solution for similar requirement&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.splunk.com/t5/Splunk-Search/Get-the-previous-day-8-9PM-data-based-on-the-date-selected-in/m-p/556978/highlight/true?search-action-id=62999991367&amp;amp;search-result-uid=556978#M158182" target="_self"&gt;https://community.splunk.com/t5/Splunk-Search/Get-the-previous-day-8-9PM-data-based-on-the-date-selected-in/m-p/556978/highlight/true?search-action-id=62999991367&amp;amp;search-result-uid=556978#M158182&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jan 2022 06:23:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Two-different-earliest-values-on-one-dashboard/m-p/581423#M47643</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-01-18T06:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: Two different earliest values on one dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Two-different-earliest-values-on-one-dashboard/m-p/581507#M47650</link>
      <description>&lt;P class="lia-align-justify"&gt;My solution worked, but I like yours better. I was looking around for a way to set more tokens on change for the time picker but was not finding it readily. I think this is just a cleaner way to do it. Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jan 2022 17:17:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Two-different-earliest-values-on-one-dashboard/m-p/581507#M47650</guid>
      <dc:creator>dstuder</dc:creator>
      <dc:date>2022-01-18T17:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: Two different earliest values on one dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Two-different-earliest-values-on-one-dashboard/m-p/581509#M47651</link>
      <description>&lt;P&gt;One question I have. I noticed when I tried to use relative_time with a date range it didn't quite work since the $timePicker.earliest$ was in epoch format. So, I had to use isnum to evaluate if $timePicker.earliest$ was numeric or not. In your example I see that you have not done that. I am curious how the inner relatime_time function would work in a date range scenario vs a relative time scenario. Do, I still need to evaluate that for date ranges?&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jan 2022 17:29:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Two-different-earliest-values-on-one-dashboard/m-p/581509#M47651</guid>
      <dc:creator>dstuder</dc:creator>
      <dc:date>2022-01-18T17:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: Two different earliest values on one dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Two-different-earliest-values-on-one-dashboard/m-p/581517#M47653</link>
      <description>&lt;P&gt;It seems to work for me without having to evaluate whether it is numeric or not. Effectively, the inner relative_time() function with now() does the evaluation for you.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jan 2022 18:03:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Two-different-earliest-values-on-one-dashboard/m-p/581517#M47653</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-01-18T18:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: Two different earliest values on one dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Two-different-earliest-values-on-one-dashboard/m-p/581519#M47654</link>
      <description>&lt;P&gt;Yeah, it does seem to work ... which is odd. When I do a relative date like Today I see that $timePicker.earliest$ is set to&amp;nbsp;&lt;STRONG&gt;@d&lt;/STRONG&gt;. So effectively it is doing this ...&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;relative_time(relative_time(now(), "@d"), "-7d@d")&lt;/LI-CODE&gt;&lt;P&gt;I can validate that works like this ...&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats count
| eval timeTest = relative_time(relative_time(now(), "@d"), "-7d@d")&lt;/LI-CODE&gt;&lt;P&gt;But I see that when I use a date range the&amp;nbsp;$timePicker.earliest$ is set to an epoch time like&amp;nbsp;&lt;SPAN&gt;&lt;STRONG&gt;1642492800&lt;/STRONG&gt;. Which should effectively be producing this ...&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;relative_time(relative_time(now(), "1642492800"), "-7d@d")&lt;/LI-CODE&gt;&lt;P&gt;If I try testing that with this it doesn't work ...&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats count
| eval timeTest = relative_time(relative_time(now(), "1642492800"), "-7d@d")&lt;/LI-CODE&gt;&lt;P&gt;But using your solution of this does seem to work.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;change&amp;gt;
        &amp;lt;eval token="daysback7"&amp;gt;relative_time(relative_time(now(),$timePicker.earliest$),"-7d@d")&amp;lt;/eval&amp;gt;
&amp;lt;/change&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;I'm not complaining but I am perplexed as to why works.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jan 2022 18:19:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Two-different-earliest-values-on-one-dashboard/m-p/581519#M47654</guid>
      <dc:creator>dstuder</dc:creator>
      <dc:date>2022-01-18T18:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: Two different earliest values on one dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Two-different-earliest-values-on-one-dashboard/m-p/581520#M47655</link>
      <description>&lt;P&gt;Try without the quotes&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats count
| eval timeTest = relative_time(relative_time(now(), 1642492800), "-7d@d")&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 18 Jan 2022 18:25:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Two-different-earliest-values-on-one-dashboard/m-p/581520#M47655</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-01-18T18:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: Two different earliest values on one dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Two-different-earliest-values-on-one-dashboard/m-p/581522#M47656</link>
      <description>&lt;P&gt;I tried that too. It doesn't work. That's why I'm a bit befuddled.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jan 2022 18:32:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Two-different-earliest-values-on-one-dashboard/m-p/581522#M47656</guid>
      <dc:creator>dstuder</dc:creator>
      <dc:date>2022-01-18T18:32:34Z</dc:date>
    </item>
  </channel>
</rss>

