<?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: Calculating Percentage in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/226577#M188326</link>
    <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;dbx query base search 
| chart count over country by status
| eval "%NotConnected"=round('NotConnecting'*100/('NotConnecting' + Monitored + 'Alert Failure' + 'Pending Setup'),2)
| untable country status count
| chart values(count) over status by country
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;dbx query base search 
| chart count over country by status
| addtotal | eval "%NotConnected"=round('NotConnecting'*100/(Total),2)
| untable country status count
| chart values(count) over status by country
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 23 Jun 2016 21:47:03 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2016-06-23T21:47:03Z</dc:date>
    <item>
      <title>Calculating Percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/226576#M188325</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
I'm having trouble finding the correct syntax and function to get the desired end result. I have a search based off of a dbx query. The search is like this:&lt;BR /&gt;
dbx query base search | chart count over status by country&lt;BR /&gt;
This returns something similiar to:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/1507i803E46474BDCF59A/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;I'd like to add a new row to the results, calculating the %NotConnected for each country.&lt;BR /&gt;
I have tried using the following to calculate the %NotConnected:&lt;/P&gt;

&lt;P&gt;stats count(eval(STATUS="NotConnecting")) AS NotConnected, count(eval(STATUS="Monitored")) AS total | eval %NotConnected=((NotConnecting/Monitored)*100&lt;/P&gt;

&lt;P&gt;doesn't seem to work and I am unable to figure out, even if it did work, how to add the calculation for each country to the current results as a new row. Hopefully this makes sense and someone can help me out. I'm fairly new to Splunk and really out of my realm on this one.&lt;/P&gt;

&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 19:13:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/226576#M188325</guid>
      <dc:creator>g038123</dc:creator>
      <dc:date>2016-06-23T19:13:24Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/226577#M188326</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;dbx query base search 
| chart count over country by status
| eval "%NotConnected"=round('NotConnecting'*100/('NotConnecting' + Monitored + 'Alert Failure' + 'Pending Setup'),2)
| untable country status count
| chart values(count) over status by country
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;dbx query base search 
| chart count over country by status
| addtotal | eval "%NotConnected"=round('NotConnecting'*100/(Total),2)
| untable country status count
| chart values(count) over status by country
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Jun 2016 21:47:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/226577#M188326</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-06-23T21:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/226578#M188327</link>
      <description>&lt;P&gt;Thank you somesoni2,&lt;/P&gt;

&lt;P&gt;You pointed me in the right direction. I ended up transposing the original data and used the following to get the totals in a new column rather than in a new row.&lt;/P&gt;

&lt;P&gt;dbx query base search &lt;BR /&gt;
| chart count over CTRY by STATUS limit=20 &lt;BR /&gt;
| eval "%NotConnected"=tostring(round(('Not Connecting'/Monitored)*100,1))+"%" &lt;BR /&gt;
| table CTRY,Monitored,"NotConnecting","Alert Monitoring Failure","Replacement", %NotConnected&lt;/P&gt;

&lt;P&gt;That worked perfectly, Thank you for the help!&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2016 18:58:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/226578#M188327</guid>
      <dc:creator>g038123</dc:creator>
      <dc:date>2016-06-24T18:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/226579#M188328</link>
      <description>&lt;P&gt;On a side note, does the eval(STATUS=="NotConnecting") need a double equals sign? I haven't played in a bit so apologies if I'm being too tangential here.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2016 12:27:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/226579#M188328</guid>
      <dc:creator>sloshburch</dc:creator>
      <dc:date>2016-06-27T12:27:29Z</dc:date>
    </item>
  </channel>
</rss>

