<?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 do I write a filter for each value of a multivalued field? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-filter-for-each-value-of-a-multivalued-field/m-p/219900#M43194</link>
    <description>&lt;P&gt;From your example you need first entry of each col not the last entry. If its indexed on different time, then try &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt; |stats last(col2) by col1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should pick up the first value seen for the field and first(col2) for last value&lt;/P&gt;

&lt;P&gt;first() returns the first seen result -&amp;gt; the most recent reference&lt;BR /&gt;
last() returns the last seen result - &amp;gt; the oldest reference&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.1/SearchReference/Commonstatsfunctions"&gt;http://docs.splunk.com/Documentation/Splunk/6.1/SearchReference/Commonstatsfunctions&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Jan 2016 16:56:18 GMT</pubDate>
    <dc:creator>renjith_nair</dc:creator>
    <dc:date>2016-01-07T16:56:18Z</dc:date>
    <item>
      <title>How do I write a filter for each value of a multivalued field?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-filter-for-each-value-of-a-multivalued-field/m-p/219899#M43193</link>
      <description>&lt;P&gt;I have a table like the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;col1      col2
value1    a
value2    b
value2    c
value1    d
value3    e
value2    f
value3    g
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now I want to reduce the output to this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;col1      col2
value1    a
value2    b
value3    e
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So always the last entry of each value of col1.&lt;BR /&gt;
Is there a way to do this?&lt;/P&gt;

&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2016 14:11:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-filter-for-each-value-of-a-multivalued-field/m-p/219899#M43193</guid>
      <dc:creator>Philip_spl</dc:creator>
      <dc:date>2016-01-07T14:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a filter for each value of a multivalued field?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-filter-for-each-value-of-a-multivalued-field/m-p/219900#M43194</link>
      <description>&lt;P&gt;From your example you need first entry of each col not the last entry. If its indexed on different time, then try &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt; |stats last(col2) by col1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should pick up the first value seen for the field and first(col2) for last value&lt;/P&gt;

&lt;P&gt;first() returns the first seen result -&amp;gt; the most recent reference&lt;BR /&gt;
last() returns the last seen result - &amp;gt; the oldest reference&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.1/SearchReference/Commonstatsfunctions"&gt;http://docs.splunk.com/Documentation/Splunk/6.1/SearchReference/Commonstatsfunctions&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2016 16:56:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-filter-for-each-value-of-a-multivalued-field/m-p/219900#M43194</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2016-01-07T16:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a filter for each value of a multivalued field?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-filter-for-each-value-of-a-multivalued-field/m-p/219901#M43195</link>
      <description>&lt;P&gt;How are you defining the order of your rows?  By time? &lt;BR /&gt;
From your example, it looks like you want to see the earliest col2 value of each col1 series.  To get that, you'd do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="myIndex" sourcetype="myData" | stats earliest(col2) as col2 by col1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want to see the last col2 value for each col1 series, you'd do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="myIndex" sourcetype="myData" | stats latest(col2) as col2 by col1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Jan 2016 17:20:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-filter-for-each-value-of-a-multivalued-field/m-p/219901#M43195</guid>
      <dc:creator>jchampagne_splu</dc:creator>
      <dc:date>2016-01-07T17:20:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a filter for each value of a multivalued field?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-filter-for-each-value-of-a-multivalued-field/m-p/219902#M43196</link>
      <description>&lt;P&gt;Thanks! That was what I was searching for &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2016 08:13:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-filter-for-each-value-of-a-multivalued-field/m-p/219902#M43196</guid>
      <dc:creator>Philip_spl</dc:creator>
      <dc:date>2016-01-12T08:13:09Z</dc:date>
    </item>
  </channel>
</rss>

