<?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 you find the top 5% of data in a table? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-the-top-5-of-data-in-a-table/m-p/417703#M174303</link>
    <description>&lt;P&gt;You probably would want to do a sort on the sum(hours) first.&lt;/P&gt;</description>
    <pubDate>Tue, 04 Dec 2018 12:13:04 GMT</pubDate>
    <dc:creator>FrankVl</dc:creator>
    <dc:date>2018-12-04T12:13:04Z</dc:date>
    <item>
      <title>How do you find the top 5% of data in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-the-top-5-of-data-in-a-table/m-p/417701#M174301</link>
      <description>&lt;P&gt;I have a table that contains hours worked against each task.&lt;/P&gt;

&lt;P&gt;Now i want to estimate the top 5% of the task(like if there are 100 tasks i want to display top 20 tasks which consumed maximum hours).&lt;/P&gt;

&lt;P&gt;My query is given below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search|stats sum(hours) by task,domain,group.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please help me to estimate the top 5% of the task.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Dec 2018 12:50:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-the-top-5-of-data-in-a-table/m-p/417701#M174301</guid>
      <dc:creator>asish_100</dc:creator>
      <dc:date>2018-12-03T12:50:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do you find the top 5% of data in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-the-top-5-of-data-in-a-table/m-p/417702#M174302</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;probably this is not a best solution but it works.&lt;BR /&gt;
just add this to the end of your query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search|stats sum(hours) as hours by task,domain,group
| sort - hours 
| streamstats count
| eventstats count as max_count
| eval percent = round(exact(exact(count * 100) / max_count), 0)
| search percent &amp;lt;= 5
| fields - count, max_count, percent
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS as FrankVl said I missed the "sort" command,&lt;BR /&gt;
so I edited this post to add it.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Dec 2018 16:32:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-the-top-5-of-data-in-a-table/m-p/417702#M174302</guid>
      <dc:creator>sergeye</dc:creator>
      <dc:date>2018-12-03T16:32:28Z</dc:date>
    </item>
    <item>
      <title>Re: How do you find the top 5% of data in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-the-top-5-of-data-in-a-table/m-p/417703#M174303</link>
      <description>&lt;P&gt;You probably would want to do a sort on the sum(hours) first.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 12:13:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-the-top-5-of-data-in-a-table/m-p/417703#M174303</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-12-04T12:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do you find the top 5% of data in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-the-top-5-of-data-in-a-table/m-p/417704#M174304</link>
      <description>&lt;P&gt;Hi FrankVl,&lt;/P&gt;

&lt;P&gt;yea, I missed it.&lt;BR /&gt;
So the query should be:&lt;BR /&gt;
base search|stats sum(hours) as hours by task,domain,group&lt;BR /&gt;
    | sort - hours &lt;BR /&gt;
    | streamstats count&lt;BR /&gt;
    | eventstats count as max_count&lt;BR /&gt;
    | eval percent = round(exact(exact(count * 100) / max_count), 0)&lt;BR /&gt;
    | search percent &amp;lt;= 5&lt;BR /&gt;
    | fields - count, max_count, percent&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:17:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-the-top-5-of-data-in-a-table/m-p/417704#M174304</guid>
      <dc:creator>sergeye</dc:creator>
      <dc:date>2020-09-29T22:17:18Z</dc:date>
    </item>
  </channel>
</rss>

