<?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 How to filter a dashboard search based on a date field that is not the default _time field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-a-dashboard-search-based-on-a-date-field-that-is/m-p/273689#M82543</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I am having trouble setting up a dashboard to filter based on a date field which isn't the default _time field.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{{search....}} | eval _time = strptime(CreatedDate, "%Y-%m-%d %H:%M:%S.%3N") | table _time CreatedDate DER_LastUpdated | sort CreatedDate asc
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I've tried to use eval to create a new field which would act as the default time dimension for the table, which looks like it works as the output table correctly shows _time value as equal to the CreatedDate value. The problem, however, is when I place this search on a dashboard with a time input that continues to filter based on the DER_LastUpdated field rather than the new _time field. My question becomes, how can I filter tables, etc. on a dashboard on time values which aren't the timestamp values stipulated when creating a dbinput?&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 09:18:05 GMT</pubDate>
    <dc:creator>jwch</dc:creator>
    <dc:date>2020-09-29T09:18:05Z</dc:date>
    <item>
      <title>How to filter a dashboard search based on a date field that is not the default _time field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-a-dashboard-search-based-on-a-date-field-that-is/m-p/273689#M82543</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I am having trouble setting up a dashboard to filter based on a date field which isn't the default _time field.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{{search....}} | eval _time = strptime(CreatedDate, "%Y-%m-%d %H:%M:%S.%3N") | table _time CreatedDate DER_LastUpdated | sort CreatedDate asc
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I've tried to use eval to create a new field which would act as the default time dimension for the table, which looks like it works as the output table correctly shows _time value as equal to the CreatedDate value. The problem, however, is when I place this search on a dashboard with a time input that continues to filter based on the DER_LastUpdated field rather than the new _time field. My question becomes, how can I filter tables, etc. on a dashboard on time values which aren't the timestamp values stipulated when creating a dbinput?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:18:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-a-dashboard-search-based-on-a-date-field-that-is/m-p/273689#M82543</guid>
      <dc:creator>jwch</dc:creator>
      <dc:date>2020-09-29T09:18:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter a dashboard search based on a date field that is not the default _time field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-a-dashboard-search-based-on-a-date-field-that-is/m-p/273690#M82544</link>
      <description>&lt;P&gt;I don't think you can do what you want this way. When you edit _time using eval - the search is already complete. The time range picker only applies to the &lt;EM&gt;first&lt;/EM&gt; search in the pipeline. &lt;/P&gt;

&lt;P&gt;AFAIK, the only way to do what you want is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere earliest=-TTT 
| eval cDate = strptime(CreatedDate, "%Y-%m-%d %H:%M:%S.%3N") 
| where cDate &amp;gt;= realEarliestTime AND cDate &amp;lt;= realLatestTime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In the initial search, you must search across a timerange that is guaranteed to pick up everything that you might want - so "TTT" may represent a long time.&lt;/P&gt;

&lt;P&gt;I wasn't sure where/how you are getting the start and end times that you want to use, so I just used "realEarliestTime" and "realLatestTime" for the example&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2016 20:43:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-a-dashboard-search-based-on-a-date-field-that-is/m-p/273690#M82544</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2016-04-04T20:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter a dashboard search based on a date field that is not the default _time field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-a-dashboard-search-based-on-a-date-field-that-is/m-p/273691#M82545</link>
      <description>&lt;P&gt;Thanks very much, Iguinn!&lt;/P&gt;

&lt;P&gt;I understand the search function a bit better thanks to your post. I've followed your steps (I think) and have am now met with a new error in the where command, specifically: "Error in 'where' command: the expression is malformed. A comparison operator is missing"&lt;/P&gt;

&lt;P&gt;I think the where command is pretty simply stating the eval field cDate needs to exist between two token fields which are used in the dashboard input, but can you spot the issue with the below xml?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="time" token="_time_tok" searchWhenChanged="true"&amp;gt;
  &amp;lt;label&amp;gt;&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;/input&amp;gt;


&amp;lt;panel&amp;gt;
  &amp;lt;table&amp;gt;
    &amp;lt;title&amp;gt;test&amp;lt;/title&amp;gt;
    &amp;lt;search&amp;gt;
      &amp;lt;query&amp;gt;index=... sourcetype=... earliest=-6mon@ | eval cDate = strftime(strptime(CreatedDate, "%Y-%m-d %H:%M:%S.%3N"), "%Y-%m-%d %H:%M:%S.%3N") | where cDate &amp;amp;gt;= $_time_tok.earliest$ AND cDate &amp;amp;lt;= $_time_tok.latest$
      &amp;lt;earliest&amp;gt;$_time_tok.earliest$&amp;lt;/earliest&amp;gt;
      &amp;lt;latest&amp;gt;$_time_tok.latest$&amp;lt;/latest&amp;gt;
    &amp;lt;/search&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Apr 2016 09:23:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-a-dashboard-search-based-on-a-date-field-that-is/m-p/273691#M82545</guid>
      <dc:creator>jwch</dc:creator>
      <dc:date>2016-04-05T09:23:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter a dashboard search based on a date field that is not the default _time field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-a-dashboard-search-based-on-a-date-field-that-is/m-p/273692#M82546</link>
      <description>&lt;P&gt;Yes, tokens (like &lt;CODE&gt;$_time_tok.earliest$&lt;/CODE&gt;) are replaced with simple substitution. The tokens are "-1d", etc. not actual timestamps.&lt;/P&gt;

&lt;P&gt;So this should work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;query&amp;gt;index=... sourcetype=... earliest=-6mon@ 
| eval cDate =strptime(CreatedDate, "%Y-%m-d %H:%M:%S.%3N")
| eval earliest = relative_time(now(),"$_time_tok.earliest$")
| eval latest=  relative_time(now(),"$_time_tok.latest$")
| where cDate &amp;amp;gt;= earliest AND cDate &amp;amp;lt;= latest
&amp;lt;/query&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Apr 2016 19:15:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-a-dashboard-search-based-on-a-date-field-that-is/m-p/273692#M82546</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2016-04-06T19:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter a dashboard search based on a date field that is not the default _time field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-a-dashboard-search-based-on-a-date-field-that-is/m-p/273693#M82547</link>
      <description>&lt;P&gt;I had the same issue.&lt;/P&gt;

&lt;P&gt;This blog post by Splunk helped me: &lt;A href="https://www.splunk.com/blog/2016/09/16/i-cant-make-my-time-range-picker-pick.html"&gt;I can’t make my time range picker pick my time field.&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Apr 2018 10:35:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-a-dashboard-search-based-on-a-date-field-that-is/m-p/273693#M82547</guid>
      <dc:creator>Yunagi</dc:creator>
      <dc:date>2018-04-30T10:35:25Z</dc:date>
    </item>
  </channel>
</rss>

