<?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: Search for 5 maximal values per field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Search-for-5-maximal-values-per-field/m-p/72788#M18224</link>
    <description>&lt;P&gt;Each event specifies a single branch sales on a single day.&lt;/P&gt;</description>
    <pubDate>Mon, 24 Jun 2013 09:30:18 GMT</pubDate>
    <dc:creator>omend</dc:creator>
    <dc:date>2013-06-24T09:30:18Z</dc:date>
    <item>
      <title>Search for 5 maximal values per field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-for-5-maximal-values-per-field/m-p/72785#M18221</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;My data in Splunk contains information about sales from different store branches. More specifically, I have the data in the format - Date, Branch_ID, Sales (Number), that describes for each branch, its sales stats overview for each day (one number).&lt;/P&gt;

&lt;P&gt;I would like to run a search that will calculate for each branch, the average of the top 5 best sales day, across the last month. More specifically, I would like to be able to reach results in the format Branch_ID Avg(Max(5)).&lt;/P&gt;

&lt;P&gt;For example, if branch_id #1 has the values 0,100,50,100,25,200,75,0,150,25, I would like the query to output #1  (200+150+100+100+75)/5=125.&lt;/P&gt;

&lt;P&gt;I tried the stats max, but it only takes the first max value. I tried to sort with limit count, but I couldn't apply the count for each branch.&lt;/P&gt;

&lt;P&gt;Any ideas would be appreciated.&lt;/P&gt;

&lt;P&gt;Thanks.&lt;BR /&gt;
Ori.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2013 06:59:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-for-5-maximal-values-per-field/m-p/72785#M18221</guid>
      <dc:creator>omend</dc:creator>
      <dc:date>2013-06-24T06:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: Search for 5 maximal values per field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-for-5-maximal-values-per-field/m-p/72786#M18222</link>
      <description>&lt;P&gt;Please post a few sample events. Also, describe how the sales values are extracted as fields (if they are);&lt;BR /&gt;
 - a single event per branch with separate fields, or &lt;BR /&gt;
 - a single event per branch with a multivalued field, or&lt;BR /&gt;
 - separate events with a single sales field in each.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2013 07:27:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-for-5-maximal-values-per-field/m-p/72786#M18222</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-06-24T07:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: Search for 5 maximal values per field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-for-5-maximal-values-per-field/m-p/72787#M18223</link>
      <description>&lt;P&gt;Assuming the last scenario, where each sale would be in a separate event;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | sort - sales_field | dedup 5 branch_id | stats avg(sales_field) as "Avg Top5 Sales" by branch_id
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This seems somewhat inefficient, but right now I can't think of anything better.&lt;/P&gt;

&lt;P&gt;/K&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2013 09:11:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-for-5-maximal-values-per-field/m-p/72787#M18223</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-06-24T09:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: Search for 5 maximal values per field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-for-5-maximal-values-per-field/m-p/72788#M18224</link>
      <description>&lt;P&gt;Each event specifies a single branch sales on a single day.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2013 09:30:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-for-5-maximal-values-per-field/m-p/72788#M18224</guid>
      <dc:creator>omend</dc:creator>
      <dc:date>2013-06-24T09:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: Search for 5 maximal values per field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-for-5-maximal-values-per-field/m-p/72789#M18225</link>
      <description>&lt;P&gt;That worked like a charm.&lt;BR /&gt;
Thank you very much!&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2013 09:31:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-for-5-maximal-values-per-field/m-p/72789#M18225</guid>
      <dc:creator>omend</dc:creator>
      <dc:date>2013-06-24T09:31:01Z</dc:date>
    </item>
  </channel>
</rss>

