<?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: Add Percentage Column next to the Count in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Add-Percentage-Column-next-to-the-Count/m-p/410371#M118391</link>
    <description>&lt;P&gt;Thank you for help. Please let me know how to add Percentage next to the Counts.&lt;/P&gt;

&lt;P&gt;Appreciate your help&lt;/P&gt;</description>
    <pubDate>Wed, 17 Apr 2019 21:44:58 GMT</pubDate>
    <dc:creator>rakeshkumar19</dc:creator>
    <dc:date>2019-04-17T21:44:58Z</dc:date>
    <item>
      <title>Add Percentage Column next to the Count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-Percentage-Column-next-to-the-Count/m-p/410369#M118389</link>
      <description>&lt;P&gt;Please help me to add percentage column &lt;/P&gt;

&lt;P&gt;SourceName, Count, %&lt;BR /&gt;
ABC  , 20, 5%&lt;BR /&gt;
XYZ, 10, 2%&lt;/P&gt;

&lt;P&gt;index=prod_sum&lt;BR /&gt;
| dedup SourceName,filestotal &lt;BR /&gt;
| stats count(filestotal) as Count by SourceName&lt;BR /&gt;
| sort - Count limit=10&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2019 20:56:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-Percentage-Column-next-to-the-Count/m-p/410369#M118389</guid>
      <dc:creator>rakeshkumar19</dc:creator>
      <dc:date>2019-04-17T20:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: Add Percentage Column next to the Count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-Percentage-Column-next-to-the-Count/m-p/410370#M118390</link>
      <description>&lt;P&gt;&lt;STRONG&gt;[UPDATED]&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Query corrected below....&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;@rakeshkumar19 rather than using stats followed by sort you should ideally use the top command which is meant for this use case. Following is run anywhere example based on Splunk's _internal index.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal sourcetype=splunkd
| top 10 component
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, since you seem to have duplicate records in your index (you should figure out why rather than using dedup). You should try the following&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=prod_sum
| stats count as Count by SourceName,filestotal 
| stats sum(Count) as Count by SourceName 
| eventstats sum(Count) as Total
| eval perc=round((Count/Total)*100,2)
| fields - Total
| sort 0 - Count 
| head 10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following stats command also gets you unique records by SourceName and filestotal &lt;CODE&gt;| stats count as Count by SourceName,filestotal&lt;/CODE&gt;. Since stats uses map-reduce it may perform better than dedup (depending on total volume of records). So please performance test and use this approach. If there is no performance improvement as per Job Inspector, your existing query can be modified as:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=prod_sum
| dedup SourceName,filestotal 
| top 10 SourceName
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Apr 2019 21:35:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-Percentage-Column-next-to-the-Count/m-p/410370#M118390</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-04-17T21:35:11Z</dc:date>
    </item>
    <item>
      <title>Re: Add Percentage Column next to the Count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-Percentage-Column-next-to-the-Count/m-p/410371#M118391</link>
      <description>&lt;P&gt;Thank you for help. Please let me know how to add Percentage next to the Counts.&lt;/P&gt;

&lt;P&gt;Appreciate your help&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2019 21:44:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-Percentage-Column-next-to-the-Count/m-p/410371#M118391</guid>
      <dc:creator>rakeshkumar19</dc:creator>
      <dc:date>2019-04-17T21:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: Add Percentage Column next to the Count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-Percentage-Column-next-to-the-Count/m-p/410372#M118392</link>
      <description>&lt;P&gt;This code worked perfectly and there was no performance issue&lt;/P&gt;

&lt;P&gt;index=prod_sum&lt;BR /&gt;
 | stats count as Count by SourceName,filestotal &lt;BR /&gt;
 | stats sum(Count) as Count by SourceName&lt;BR /&gt;
 | sort 0 - Count &lt;BR /&gt;
 | head 10&lt;/P&gt;

&lt;P&gt;How to add percentage column ?&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2019 21:56:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-Percentage-Column-next-to-the-Count/m-p/410372#M118392</guid>
      <dc:creator>rakeshkumar19</dc:creator>
      <dc:date>2019-04-17T21:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: Add Percentage Column next to the Count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-Percentage-Column-next-to-the-Count/m-p/410373#M118393</link>
      <description>&lt;P&gt;@rakeshkumar19 sorry I missed percent calculation with stats. I have updated the query please check!&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 00:40:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-Percentage-Column-next-to-the-Count/m-p/410373#M118393</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-04-18T00:40:33Z</dc:date>
    </item>
    <item>
      <title>Re: Add Percentage Column next to the Count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-Percentage-Column-next-to-the-Count/m-p/410374#M118394</link>
      <description>&lt;P&gt;hi&lt;/P&gt;

&lt;P&gt;try the following to add %&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.... | eval perc=round((Count/Total)*100,2)."%"
|rename perc as % | fields - Total
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Apr 2019 02:27:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-Percentage-Column-next-to-the-Count/m-p/410374#M118394</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-04-18T02:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: Add Percentage Column next to the Count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-Percentage-Column-next-to-the-Count/m-p/410375#M118395</link>
      <description>&lt;P&gt;Thank you for your help. The query is running as expected.&lt;BR /&gt;
Any place where I can explore the Splunk functions and usage.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 13:48:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-Percentage-Column-next-to-the-Count/m-p/410375#M118395</guid>
      <dc:creator>rakeshkumar19</dc:creator>
      <dc:date>2019-04-18T13:48:38Z</dc:date>
    </item>
    <item>
      <title>Re: Add Percentage Column next to the Count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-Percentage-Column-next-to-the-Count/m-p/410376#M118396</link>
      <description>&lt;P&gt;@rakeshkumar19 Splunk Docs is the best place with list of all commands and examples of their usage. You can check out &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Commandsbycategory"&gt;Search Reference&lt;/A&gt; Documentation link.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 21:14:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-Percentage-Column-next-to-the-Count/m-p/410376#M118396</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-04-18T21:14:34Z</dc:date>
    </item>
  </channel>
</rss>

