<?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 Percentage Calculation in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Percentage-Calculation/m-p/115563#M30636</link>
    <description>&lt;P&gt;My REGEX:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "\sof (?&amp;lt;Name&amp;gt;[A-Za-z0-9_]+)" | rex "\sdeposit \((?&amp;lt;Deposit&amp;gt;\d+)" | rex "\s*withdrawal \((?&amp;lt;Withdrawal&amp;gt;\d+)" | table Name Deposit Withdrawal | addtotals Withdrawal "\s*withdrawal \((?&amp;lt;Withdrawal&amp;gt;\d+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The problem:&lt;BR /&gt;
I would like to have the percentage of the Withdrawn amount.  So for example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;John_Doe2   Deposit 100   Withdrawal 90   
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to add a column that shows the percentage "%" and add the calculation of that amount into my REGEX.  Here's what I have so far:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "\sof (?&amp;lt;Name&amp;gt;[A-Za-z0-9_]+)" | rex "\sdeposit \((?&amp;lt;Deposit&amp;gt;\d+)" | rex "\s*withdrawal \((?&amp;lt;Withdrawal&amp;gt;\d+)" | table Name Deposit Withdrawal | addtotals Withdrawal "\s*withdrawal \((?&amp;lt;Withdrawal&amp;gt;\d+)" | stats sum(Deposit) sum(Withdrawal) by Name | eval percent=(Withdrawal/Deposit) | table percent
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried different combinations of eval and stats but keep coming up empty.  Any assistance would be much appreciated.&lt;/P&gt;</description>
    <pubDate>Tue, 01 Apr 2014 21:56:43 GMT</pubDate>
    <dc:creator>rpascua</dc:creator>
    <dc:date>2014-04-01T21:56:43Z</dc:date>
    <item>
      <title>Percentage Calculation</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Percentage-Calculation/m-p/115563#M30636</link>
      <description>&lt;P&gt;My REGEX:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "\sof (?&amp;lt;Name&amp;gt;[A-Za-z0-9_]+)" | rex "\sdeposit \((?&amp;lt;Deposit&amp;gt;\d+)" | rex "\s*withdrawal \((?&amp;lt;Withdrawal&amp;gt;\d+)" | table Name Deposit Withdrawal | addtotals Withdrawal "\s*withdrawal \((?&amp;lt;Withdrawal&amp;gt;\d+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The problem:&lt;BR /&gt;
I would like to have the percentage of the Withdrawn amount.  So for example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;John_Doe2   Deposit 100   Withdrawal 90   
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to add a column that shows the percentage "%" and add the calculation of that amount into my REGEX.  Here's what I have so far:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "\sof (?&amp;lt;Name&amp;gt;[A-Za-z0-9_]+)" | rex "\sdeposit \((?&amp;lt;Deposit&amp;gt;\d+)" | rex "\s*withdrawal \((?&amp;lt;Withdrawal&amp;gt;\d+)" | table Name Deposit Withdrawal | addtotals Withdrawal "\s*withdrawal \((?&amp;lt;Withdrawal&amp;gt;\d+)" | stats sum(Deposit) sum(Withdrawal) by Name | eval percent=(Withdrawal/Deposit) | table percent
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried different combinations of eval and stats but keep coming up empty.  Any assistance would be much appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Apr 2014 21:56:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Percentage-Calculation/m-p/115563#M30636</guid>
      <dc:creator>rpascua</dc:creator>
      <dc:date>2014-04-01T21:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: Percentage Calculation</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Percentage-Calculation/m-p/115564#M30637</link>
      <description>&lt;P&gt;Your &lt;CODE&gt;stats&lt;/CODE&gt; produces fields called &lt;CODE&gt;sum(fieldname)&lt;/CODE&gt;, rename them before doing further calculations like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats sum(Deposit) as sum_deposit sum(Withdrawal) as sum_withdrawal | eval percent = sum_withdrawal/sum_deposit*100."%"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note, your call to &lt;CODE&gt;addtotals&lt;/CODE&gt; contains odd regular expressions that make little sense there.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Apr 2014 22:02:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Percentage-Calculation/m-p/115564#M30637</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-04-01T22:02:51Z</dc:date>
    </item>
  </channel>
</rss>

