<?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: top N results of values(X) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/top-N-results-of-values-X/m-p/163694#M46477</link>
    <description>&lt;P&gt;Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$SEARCH | stats count dc(mymail) as unique count(mymail) as hits values(mymail) as list by VAR 
| eval sno=mvrange(0,10,1) | eval list=mvzip(list,sno,",") |nomv list| eval list=replace(list,"(,\d+)"," ") | makemv list
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The no '10' in the mvrange command denotes you will be returned first 10 values from the multivalued field 'list'&lt;/P&gt;</description>
    <pubDate>Wed, 30 Jul 2014 17:18:46 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2014-07-30T17:18:46Z</dc:date>
    <item>
      <title>top N results of values(X)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/top-N-results-of-values-X/m-p/163693#M46476</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
I have  a column list  received from "values(mymail)"&lt;/P&gt;

&lt;P&gt;&lt;A href="mailto:abra@sth.com"&gt;abra@sth.com&lt;/A&gt;&lt;BR /&gt;
&lt;A href="mailto:cada@sth.com"&gt;cada@sth.com&lt;/A&gt;&lt;BR /&gt;
&lt;A href="mailto:bra@sth.com"&gt;bra@sth.com&lt;/A&gt;&lt;BR /&gt;
&lt;A href="mailto:this@sth.com"&gt;this@sth.com&lt;/A&gt;&lt;BR /&gt;
&lt;A href="mailto:is@sth.com"&gt;is@sth.com&lt;/A&gt;&lt;BR /&gt;
&lt;A href="mailto:anew@sth.com"&gt;anew@sth.com&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I need to get top/head N results of that list with the idea that values(mymail) can reach thousands of rows.&lt;/P&gt;

&lt;P&gt;The whole search string related to the question is :&lt;/P&gt;

&lt;P&gt;$SEARCH | stats count  dc(mymail) as unique count(mymail) as hits values(mymail)  as list by VAR&lt;/P&gt;

&lt;P&gt;How do I do that ? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;I tried with eval &lt;BR /&gt;
just before |stats like eval email_list=(values(mymail)|head 10 ), but it seems not right&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jul 2014 14:24:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/top-N-results-of-values-X/m-p/163693#M46476</guid>
      <dc:creator>atanasmitev</dc:creator>
      <dc:date>2014-07-30T14:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: top N results of values(X)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/top-N-results-of-values-X/m-p/163694#M46477</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$SEARCH | stats count dc(mymail) as unique count(mymail) as hits values(mymail) as list by VAR 
| eval sno=mvrange(0,10,1) | eval list=mvzip(list,sno,",") |nomv list| eval list=replace(list,"(,\d+)"," ") | makemv list
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The no '10' in the mvrange command denotes you will be returned first 10 values from the multivalued field 'list'&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jul 2014 17:18:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/top-N-results-of-values-X/m-p/163694#M46477</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-07-30T17:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: top N results of values(X)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/top-N-results-of-values-X/m-p/163695#M46478</link>
      <description>&lt;P&gt;You could maybe use the following to break out the individual items in the list field but am having trouble imagining what the rest of your stats command output is - haven't had enough caffeine yet I suppose.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makemv list | mvexpand list
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;At any rate you would then need another stats (+ sort &amp;amp; head) or top command to then get your top X.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jul 2014 12:09:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/top-N-results-of-values-X/m-p/163695#M46478</guid>
      <dc:creator>Runals</dc:creator>
      <dc:date>2014-07-31T12:09:38Z</dc:date>
    </item>
  </channel>
</rss>

