<?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: Summing of row in a column on condition in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Summing-of-row-in-a-column-on-condition/m-p/127570#M184364</link>
    <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere
| stats sum(ColumnC) as CTotal by ColumnA ColumnB  
| eventstats sum(CTotal) as SiteTotal by ColumnA
| eval Percentage = round(CTotal*100/SiteTotal,0)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 28 Jan 2014 06:43:46 GMT</pubDate>
    <dc:creator>lguinn2</dc:creator>
    <dc:date>2014-01-28T06:43:46Z</dc:date>
    <item>
      <title>Summing of row in a column on condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Summing-of-row-in-a-column-on-condition/m-p/127569#M184363</link>
      <description>&lt;P&gt;I have three columns&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ColumnA     ColumnB     ColumnC
vin          1            1
vin          1            2 
vin          2            3
kum          1            1
kum          1            2
kum          2            3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I wanted sum columnc and find out the percentage by ColumnA&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ColumnA     ColumnB     ColumnC     "Totalof Columnc by Site" Percentage
vin          1            3              6                       50
             2            3              6                       50
kum          1            3              6                       50
             2            3              6                       50      
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Jan 2014 06:30:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Summing-of-row-in-a-column-on-condition/m-p/127569#M184363</guid>
      <dc:creator>vinay_ks04</dc:creator>
      <dc:date>2014-01-28T06:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: Summing of row in a column on condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Summing-of-row-in-a-column-on-condition/m-p/127570#M184364</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere
| stats sum(ColumnC) as CTotal by ColumnA ColumnB  
| eventstats sum(CTotal) as SiteTotal by ColumnA
| eval Percentage = round(CTotal*100/SiteTotal,0)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Jan 2014 06:43:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Summing-of-row-in-a-column-on-condition/m-p/127570#M184364</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2014-01-28T06:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: Summing of row in a column on condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Summing-of-row-in-a-column-on-condition/m-p/127571#M184365</link>
      <description>&lt;P&gt;Based on your result, it looks like you want to add something like this to the end of your search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats sum(ColumnC) as "Total of ColumnC by Site" by ColumnA, ColumnB | eventstats sum(ColumnC) as OverallColumnCTotal | eval Percentage = round("Total of ColumnC by Site" / OverallColumnCTotal * 100,0) | table ColumnA ColumnB ColumnC "Total of ColumnC by Site" Percentage
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Does that match what you're looking for?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2014 06:44:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Summing-of-row-in-a-column-on-condition/m-p/127571#M184365</guid>
      <dc:creator>David</dc:creator>
      <dc:date>2014-01-28T06:44:34Z</dc:date>
    </item>
    <item>
      <title>Re: Summing of row in a column on condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Summing-of-row-in-a-column-on-condition/m-p/127572#M184366</link>
      <description>&lt;P&gt;Thanks a lot it is working.......&lt;/P&gt;

&lt;P&gt;I am adding one more column to just print the value which is there in the log, but it is not printing.&lt;BR /&gt;
I am using "list(Config) As "Config Name"&lt;/P&gt;

&lt;P&gt;index="autolab_prod" sourcetype="Percentage_Usage_Config"  | stats sum(taskcount) as TOTAL_Task by Site ConfigID | eventstats sum(TOTAL_Task) as SiteTotal by Site | eval percent=round(100*TOTAL_Task/SiteTotal,0) | stats list(ConfigID) AS "CONFIG ID", list(CONFIG) AS "CONFIG NAME", list(TOTAL_Task) AS "TOTAL_Task", list(SiteTotal)  AS SiteTotal, list(percent) as PERCENTAGE  by Site&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:44:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Summing-of-row-in-a-column-on-condition/m-p/127572#M184366</guid>
      <dc:creator>vinay_ks04</dc:creator>
      <dc:date>2020-09-28T15:44:10Z</dc:date>
    </item>
    <item>
      <title>Re: Summing of row in a column on condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Summing-of-row-in-a-column-on-condition/m-p/127573#M184367</link>
      <description>&lt;P&gt;thank you, &lt;BR /&gt;
yes, but I am not able to add one more column.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2014 07:28:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Summing-of-row-in-a-column-on-condition/m-p/127573#M184367</guid>
      <dc:creator>vinay_ks04</dc:creator>
      <dc:date>2014-01-28T07:28:30Z</dc:date>
    </item>
    <item>
      <title>Re: Summing of row in a column on condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Summing-of-row-in-a-column-on-condition/m-p/127574#M184368</link>
      <description>&lt;P&gt;Thanks a lot &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
I have added extra columnname in stats, below is my query.&lt;/P&gt;

&lt;P&gt;index="autolab_prod" sourcetype="Percentage_Usage_Config"  | stats sum(taskcount) as TOTAL_Task by Site ConfigID CONFIG | eventstats sum(TOTAL_Task) as SiteTotal by Site | eval percent=round(100*TOTAL_Task/SiteTotal,0) | stats list(ConfigID) AS "CONFIG ID", list(CONFIG) AS CONFIGNAME, list(TOTAL_Task) AS "TASK_TOTAL", list(SiteTotal)  AS TASK_TOTAL_COUNT, list(percent) as PERCENTAGE  by Site&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:44:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Summing-of-row-in-a-column-on-condition/m-p/127574#M184368</guid>
      <dc:creator>vinay_ks04</dc:creator>
      <dc:date>2020-09-28T15:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: Summing of row in a column on condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Summing-of-row-in-a-column-on-condition/m-p/127575#M184369</link>
      <description>&lt;P&gt;After the &lt;CODE&gt;stats&lt;/CODE&gt; command, your search pipeline no longer has any fields except the ones that are the result of the command: TOTAL_Task Site and ConfigID&lt;/P&gt;

&lt;P&gt;So if you want the CONFIG to be included, you will have to include it in the &lt;CODE&gt;by&lt;/CODE&gt; clause of the &lt;CODE&gt;stats&lt;/CODE&gt; command.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2014 07:39:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Summing-of-row-in-a-column-on-condition/m-p/127575#M184369</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2014-01-30T07:39:41Z</dc:date>
    </item>
  </channel>
</rss>

