<?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 see only earliest and latest values in a field. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-see-only-earliest-and-latest-values-in-a-field/m-p/488317#M141441</link>
    <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/8502iAB6638E6205D24FA/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;any clues why this is happening?&lt;/P&gt;</description>
    <pubDate>Mon, 09 Mar 2020 14:06:16 GMT</pubDate>
    <dc:creator>franciscof</dc:creator>
    <dc:date>2020-03-09T14:06:16Z</dc:date>
    <item>
      <title>How to see only earliest and latest values in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-see-only-earliest-and-latest-values-in-a-field/m-p/488312#M141436</link>
      <description>&lt;P&gt;I'm having an issue because I need to show in a report only the first ticket received by an agent and the latest one, so all the other tickets in the middle I have to leave them behind. Here is the evidence:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/8503iEA2A92E899903726/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Of all the tickets assigned to user1 or user2, how can I capture only the oldest and newest one?&lt;/P&gt;
&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2020 22:02:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-see-only-earliest-and-latest-values-in-a-field/m-p/488312#M141436</guid>
      <dc:creator>franciscof</dc:creator>
      <dc:date>2020-06-23T22:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to see only earliest and latest values in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-see-only-earliest-and-latest-values-in-a-field/m-p/488313#M141437</link>
      <description>&lt;P&gt;Hi @franciscof,&lt;BR /&gt;
did you tried using earliest and latest in stats?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=your_index ticket_arrival=*
| eval ticket_arrival=strptime(ticket_arrival,"%d/%m/%y - %H:%M:%S"")
| stats earliest(ticket_arrival) AS earliest latest(ticket_arrival) AS latest BY user
| eval earliest=strftime(earliest,"%d/%m/%y - %H:%M:%S""), latest=strftime(latest,"%d/%m/%y - %H:%M:%S"")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please check the format of the ticket_arrival field, because I'm not sure about the spaces before hours.&lt;BR /&gt;
Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 06 Mar 2020 14:41:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-see-only-earliest-and-latest-values-in-a-field/m-p/488313#M141437</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-03-06T14:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to see only earliest and latest values in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-see-only-earliest-and-latest-values-in-a-field/m-p/488314#M141438</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="user,ticket_arrival
user1,02/03/20 - 12:43:47
user1,02/03/20 - 12:44:40
user1,03/03/20 - 16:05:08
user1,04/03/20 - 15:39:37
user1,05/03/20 - 15:22:25
user2,04/03/20 - 18:03:13
user2,04/03/20 - 09:39:24
user2,04/03/20 - 10:32:35
user2,04/03/20 - 15:05:25
user2,05/03/20 - 10:46:35
user2,05/03/20 - 10:47:10"
| multikv forceheader=1
| table user,ticket_arrival
| rename COMMENT as "this is sample your stats output, from here, the logic"
| eval _time=strptime(ticket_arrival,"%d/%m/%y - %T")
| eventstats min(_time) as e_time max(_time) as l_time by user
| where _time=e_time OR _time=l_time
| table user,ticket_arrival
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi, If you provide your query, there is more easy query.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Mar 2020 14:43:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-see-only-earliest-and-latest-values-in-a-field/m-p/488314#M141438</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-03-06T14:43:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to see only earliest and latest values in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-see-only-earliest-and-latest-values-in-a-field/m-p/488315#M141439</link>
      <description>&lt;P&gt;The basic answer is to use &lt;CODE&gt;earliest()&lt;/CODE&gt; and &lt;CODE&gt;latest()&lt;/CODE&gt; but you can also use &lt;CODE&gt;first()&lt;/CODE&gt; and &lt;CODE&gt;last()&lt;/CODE&gt; just be aware that the former pair leverages the &lt;CODE&gt;_time&lt;/CODE&gt; field  (which may/not be present and may/not be correct) whereas the latter leverages the order of the data which you can control by sorting it.   Both honor the &lt;CODE&gt;BY&lt;/CODE&gt; section of &lt;CODE&gt;stats&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Mar 2020 15:29:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-see-only-earliest-and-latest-values-in-a-field/m-p/488315#M141439</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2020-03-06T15:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to see only earliest and latest values in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-see-only-earliest-and-latest-values-in-a-field/m-p/488316#M141440</link>
      <description>&lt;P&gt;Hi @gcusello , I did tried it and I think it didn't work and I can't figure out why. Below (in an answer) I'll show you what I got&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 14:05:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-see-only-earliest-and-latest-values-in-a-field/m-p/488316#M141440</guid>
      <dc:creator>franciscof</dc:creator>
      <dc:date>2020-03-09T14:05:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to see only earliest and latest values in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-see-only-earliest-and-latest-values-in-a-field/m-p/488317#M141441</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/8502iAB6638E6205D24FA/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;any clues why this is happening?&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 14:06:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-see-only-earliest-and-latest-values-in-a-field/m-p/488317#M141441</guid>
      <dc:creator>franciscof</dc:creator>
      <dc:date>2020-03-09T14:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to see only earliest and latest values in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-see-only-earliest-and-latest-values-in-a-field/m-p/488318#M141442</link>
      <description>&lt;P&gt;Do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval ticket_arrival = strptime(replace(ticket_arrival, "\s", ""), "%d/%m/%y-%H:%M:%S") | stats min(ticket_arrival) as min_time, max(ticket_arrival) as max_time by user | eval min_time=strftime(min_time, "%d/%m/%y-%H:%M:%S"), max_time=strftime(max_time, "%d/%m/%y-%H:%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Mar 2020 14:31:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-see-only-earliest-and-latest-values-in-a-field/m-p/488318#M141442</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-03-09T14:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to see only earliest and latest values in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-see-only-earliest-and-latest-values-in-a-field/m-p/488319#M141443</link>
      <description>&lt;P&gt;Solved it! All it was needed was to replace stats earliest and latest with stats first and last!&lt;/P&gt;

&lt;P&gt;Thank you for your help&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 14:40:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-see-only-earliest-and-latest-values-in-a-field/m-p/488319#M141443</guid>
      <dc:creator>franciscof</dc:creator>
      <dc:date>2020-03-09T14:40:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to see only earliest and latest values in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-see-only-earliest-and-latest-values-in-a-field/m-p/488320#M141444</link>
      <description>&lt;P&gt;you're welcome!&lt;BR /&gt;
Ciao and next time.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 14:53:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-see-only-earliest-and-latest-values-in-a-field/m-p/488320#M141444</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-03-09T14:53:42Z</dc:date>
    </item>
  </channel>
</rss>

