<?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 Perform calculation based on 2 stats count result in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Perform-calculation-based-on-2-stats-count-result/m-p/293111#M88461</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I've a requirement to perform the following calculation in percentage.&lt;/P&gt;

&lt;P&gt;First query is as below and single value result is 50&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    index=* 
    | rex field=_raw "Product ABC.*client\=(?&amp;lt;client&amp;gt;[\w+]+)" 
    | stats count(client) as Count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then I've another query and single value result is 10:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* 
| rex field=_raw "Broken Product.*productid\=(?&amp;lt;productid&amp;gt;[\w+]+)" 
| stats count(productid)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I need to perform the calculation based on the result of above 2 queries. The calculation formula should be 10/50 = 20%. How can I achieve it to come out with 20% as the output of the calculation in Splunk?&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Tue, 27 Mar 2018 06:43:45 GMT</pubDate>
    <dc:creator>krusovice</dc:creator>
    <dc:date>2018-03-27T06:43:45Z</dc:date>
    <item>
      <title>Perform calculation based on 2 stats count result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Perform-calculation-based-on-2-stats-count-result/m-p/293111#M88461</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I've a requirement to perform the following calculation in percentage.&lt;/P&gt;

&lt;P&gt;First query is as below and single value result is 50&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    index=* 
    | rex field=_raw "Product ABC.*client\=(?&amp;lt;client&amp;gt;[\w+]+)" 
    | stats count(client) as Count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then I've another query and single value result is 10:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* 
| rex field=_raw "Broken Product.*productid\=(?&amp;lt;productid&amp;gt;[\w+]+)" 
| stats count(productid)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I need to perform the calculation based on the result of above 2 queries. The calculation formula should be 10/50 = 20%. How can I achieve it to come out with 20% as the output of the calculation in Splunk?&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 06:43:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Perform-calculation-based-on-2-stats-count-result/m-p/293111#M88461</guid>
      <dc:creator>krusovice</dc:creator>
      <dc:date>2018-03-27T06:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: Perform calculation based on 2 stats count result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Perform-calculation-based-on-2-stats-count-result/m-p/293112#M88462</link>
      <description>&lt;P&gt;try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=*|rex field=_raw "Product ABC.*client\=(?&amp;lt;client&amp;gt;[\w+]+)" 
| rex field=_raw "Broken Product.*productid\=(?&amp;lt;productid&amp;gt;[\w+]+)" 
| stats count(client) as clientcount , count(productid) as productcount
|eval percentage=((productcount/clientcount)*100)."%"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Mar 2018 06:52:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Perform-calculation-based-on-2-stats-count-result/m-p/293112#M88462</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-03-27T06:52:13Z</dc:date>
    </item>
    <item>
      <title>Re: Perform calculation based on 2 stats count result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Perform-calculation-based-on-2-stats-count-result/m-p/293113#M88463</link>
      <description>&lt;P&gt;Hi @493669,&lt;/P&gt;

&lt;P&gt;It's work! Thank you. Can you update as answer so that I can accept it officially?&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 07:02:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Perform-calculation-based-on-2-stats-count-result/m-p/293113#M88463</guid>
      <dc:creator>krusovice</dc:creator>
      <dc:date>2018-03-27T07:02:31Z</dc:date>
    </item>
  </channel>
</rss>

