<?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 How to calculate Top limit=10 OR head 10 not working by Count? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-Top-limit-10-OR-head-10-not-working-by-Count/m-p/606200#M210815</link>
    <description>&lt;P&gt;Hi Team&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a query where I am doing the TimeChart &amp;amp; % (not using the timechart and calculate the % in timechart line as this doesn't solve my purpose hence using it this say)&lt;BR /&gt;&lt;BR /&gt;The query is working fine however it shows all the data on field and I want to have that field only show top 10&amp;nbsp; by volume or count&lt;BR /&gt;&lt;BR /&gt;Query&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=xyz (catcode="*") (prodid="1") (prodcat="*") success="*"
| bucket _time span="1d"

| eval TheError=if(success="false" AND Error_Value like "%%",count,0)
| eval Success=if(success="true",count,0)
| stats sum(TheError) as "Failed", sum(Success) as "Passed", sum(count) as Total by _time, catcode
| eval Failed_Percent=round((Failed/Total)*100,2)
| fields _time, catcode, Failed_Percent
| xyseries _time, catcode, Failed_Percent&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I don't want to do the 'eventstats' because it will count all on prodid level and not at catcode level hence this query&lt;BR /&gt;This query counts all false with error on catcode....and count all attempts on individual catcode, then calculate the %&lt;BR /&gt;with event stats the total count will be not at catcode but all prodid count i.e. all catcode's total attempt's count&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 19 Jul 2022 16:04:02 GMT</pubDate>
    <dc:creator>beriwalnishant</dc:creator>
    <dc:date>2022-07-19T16:04:02Z</dc:date>
    <item>
      <title>How to calculate Top limit=10 OR head 10 not working by Count?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-Top-limit-10-OR-head-10-not-working-by-Count/m-p/606200#M210815</link>
      <description>&lt;P&gt;Hi Team&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a query where I am doing the TimeChart &amp;amp; % (not using the timechart and calculate the % in timechart line as this doesn't solve my purpose hence using it this say)&lt;BR /&gt;&lt;BR /&gt;The query is working fine however it shows all the data on field and I want to have that field only show top 10&amp;nbsp; by volume or count&lt;BR /&gt;&lt;BR /&gt;Query&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=xyz (catcode="*") (prodid="1") (prodcat="*") success="*"
| bucket _time span="1d"

| eval TheError=if(success="false" AND Error_Value like "%%",count,0)
| eval Success=if(success="true",count,0)
| stats sum(TheError) as "Failed", sum(Success) as "Passed", sum(count) as Total by _time, catcode
| eval Failed_Percent=round((Failed/Total)*100,2)
| fields _time, catcode, Failed_Percent
| xyseries _time, catcode, Failed_Percent&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I don't want to do the 'eventstats' because it will count all on prodid level and not at catcode level hence this query&lt;BR /&gt;This query counts all false with error on catcode....and count all attempts on individual catcode, then calculate the %&lt;BR /&gt;with event stats the total count will be not at catcode but all prodid count i.e. all catcode's total attempt's count&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 16:04:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-Top-limit-10-OR-head-10-not-working-by-Count/m-p/606200#M210815</guid>
      <dc:creator>beriwalnishant</dc:creator>
      <dc:date>2022-07-19T16:04:02Z</dc:date>
    </item>
    <item>
      <title>Re: Top limit=10 OR head 10 not working by Count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-Top-limit-10-OR-head-10-not-working-by-Count/m-p/606201#M210816</link>
      <description>&lt;P&gt;To show only the 10 results with the highest values of Failed_Percent you can use the &lt;FONT face="courier new,courier"&gt;sort&lt;/FONT&gt; command.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;...
| xyseries _time, catcode, Failed_Percent
| sort 10 - Failed_Percent&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 15:47:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-Top-limit-10-OR-head-10-not-working-by-Count/m-p/606201#M210816</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-07-19T15:47:49Z</dc:date>
    </item>
    <item>
      <title>Re: Top limit=10 OR head 10 not working by Count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-Top-limit-10-OR-head-10-not-working-by-Count/m-p/606202#M210817</link>
      <description>&lt;P&gt;At this point in your search:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=xyz (catcode="*") (prodid="1") (prodcat="*") success="*"
| bucket _time span="1d"

| eval TheError=if(success="false" AND Error_Value like "%%",count,0)
| eval Success=if(success="true",count,0)
| stats sum(TheError) as "Failed", sum(Success) as "Passed", sum(count) as Total by _time, catcode&lt;/LI-CODE&gt;&lt;P&gt;you have 5 fields, _time, catcode, Failed, Passed and Total.&lt;/P&gt;&lt;P&gt;Where does prodId come from?&lt;/P&gt;&lt;P&gt;If you use eventstats at this point, you can sum the Total to find count all the events by catcode.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=xyz (catcode="*") (prodid="1") (prodcat="*") success="*"
| bucket _time span="1d"

| eval TheError=if(success="false" AND Error_Value like "%%",count,0)
| eval Success=if(success="true",count,0)
| stats sum(TheError) as "Failed", sum(Success) as "Passed", sum(count) as Total by _time, catcode
| eventstats sum(Total) as Total_catcode by catcode&lt;/LI-CODE&gt;&lt;P&gt;Does that help you? If not, please explain with some examples of what you are currently have and what you would like to see&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 15:52:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-Top-limit-10-OR-head-10-not-working-by-Count/m-p/606202#M210817</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-07-19T15:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: Top limit=10 OR head 10 not working by Count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-Top-limit-10-OR-head-10-not-working-by-Count/m-p/606260#M210850</link>
      <description>&lt;P&gt;This only sorts the time and instead of 10 showing single column of catcode...the one is hihest&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 03:57:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-Top-limit-10-OR-head-10-not-working-by-Count/m-p/606260#M210850</guid>
      <dc:creator>beriwalnishant</dc:creator>
      <dc:date>2022-07-20T03:57:45Z</dc:date>
    </item>
  </channel>
</rss>

