<?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 aggregating field values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/aggregating-field-values/m-p/30976#M6354</link>
    <description>&lt;P&gt;I have a specific field that has similar values that I want to group together and obtain an average of another fields value. For example, if the field had the values Bob Sanders, Bob Baker, Sam Winters, and Sam Smith. Each one of these has a numeric value in another field. I would want to group the Bob's and Sam's together and get the average of the values of the numeric field for each.&lt;/P&gt;

&lt;P&gt;Like this&lt;BR /&gt;
Bob, 20&lt;BR /&gt;
Sam, 36 &lt;/P&gt;

&lt;P&gt;Anybody have idea's?&lt;/P&gt;</description>
    <pubDate>Thu, 19 Apr 2012 15:38:18 GMT</pubDate>
    <dc:creator>jedatt01</dc:creator>
    <dc:date>2012-04-19T15:38:18Z</dc:date>
    <item>
      <title>aggregating field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/aggregating-field-values/m-p/30976#M6354</link>
      <description>&lt;P&gt;I have a specific field that has similar values that I want to group together and obtain an average of another fields value. For example, if the field had the values Bob Sanders, Bob Baker, Sam Winters, and Sam Smith. Each one of these has a numeric value in another field. I would want to group the Bob's and Sam's together and get the average of the values of the numeric field for each.&lt;/P&gt;

&lt;P&gt;Like this&lt;BR /&gt;
Bob, 20&lt;BR /&gt;
Sam, 36 &lt;/P&gt;

&lt;P&gt;Anybody have idea's?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2012 15:38:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/aggregating-field-values/m-p/30976#M6354</guid>
      <dc:creator>jedatt01</dc:creator>
      <dc:date>2012-04-19T15:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: aggregating field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/aggregating-field-values/m-p/30977#M6355</link>
      <description>&lt;P&gt;Assuming that the CSV looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;first,last,age
Bob,Sanders,23
Sam,Johnson,36
Bob,Jackson,39
Sam,Conrad,21
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The search would look like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;first=Bob OR first=Sam | stats avg(age) by first
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The results would look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;first     avg(age)
------------------
Bob       31
Sam       28.5
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Apr 2012 16:20:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/aggregating-field-values/m-p/30977#M6355</guid>
      <dc:creator>araitz</dc:creator>
      <dc:date>2012-04-19T16:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: aggregating field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/aggregating-field-values/m-p/30978#M6356</link>
      <description>&lt;P&gt;hey araitz, this is jdattilo. It's actually a little more complicated than I first explained. I'm using fictitious data here, but lets say that the data in first and last fields are actually one single field. Can I do a kind of field 'contains' or 'starts with' type of thing? I tried to use substring, which kind of worked but not all my fields entries are the same length so some letters got cut off.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2012 17:52:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/aggregating-field-values/m-p/30978#M6356</guid>
      <dc:creator>jedatt01</dc:creator>
      <dc:date>2012-04-19T17:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: aggregating field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/aggregating-field-values/m-p/30979#M6357</link>
      <description>&lt;P&gt;The best approach would be to use a field extraction on the field.  Conf files are best (using SOURCE_KEY in transforms.conf), but you can also try it in the search language.  Let's assume that there is a name field that looks like "Bob Johnson":&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;`name="Bob *" OR name="Sam *" | rex field=name "(?&amp;lt;first_name&amp;gt;\S+)" | stat avg(age) by first_name`
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Apr 2012 17:56:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/aggregating-field-values/m-p/30979#M6357</guid>
      <dc:creator>araitz</dc:creator>
      <dc:date>2012-04-19T17:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: aggregating field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/aggregating-field-values/m-p/30980#M6358</link>
      <description>&lt;P&gt;What you have is a multivalue field. To get to the values use the mvindex command.&lt;BR /&gt;
mvindex(multifield, 2)&lt;/P&gt;

&lt;P&gt;First check if a field is multivalued:&lt;BR /&gt;
mvcount(multifield)&lt;/P&gt;

&lt;P&gt;To get to the values In your case:&lt;BR /&gt;
| eval name=mvindex(yourmultifield,0) | eval surname=mvindex(yourmultifield,1) | ...&lt;/P&gt;

&lt;P&gt;You can also split a field to get a multivalued field.&lt;BR /&gt;
split(foo, ";")&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonEvalFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2012 22:37:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/aggregating-field-values/m-p/30980#M6358</guid>
      <dc:creator>amstaff</dc:creator>
      <dc:date>2012-04-19T22:37:59Z</dc:date>
    </item>
  </channel>
</rss>

