<?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: Calculate Percentage in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Calculate-Percentage/m-p/69065#M17348</link>
    <description>&lt;P&gt;actualcount is a static value that is currently in a lookup file&lt;/P&gt;</description>
    <pubDate>Tue, 25 Sep 2012 14:03:29 GMT</pubDate>
    <dc:creator>gnovak</dc:creator>
    <dc:date>2012-09-25T14:03:29Z</dc:date>
    <item>
      <title>Calculate Percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-Percentage/m-p/69063#M17346</link>
      <description>&lt;P&gt;I've been going around in circles on this all day and at this point figured I would post my question here:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="EPPWEB" source="/opt/log/dotblah/web_server/info.log" OR source="/opt/log/dotblah/*/web_server/info.log" WAT | dedup registrar | stats count(registrar) as numviewed by description,registry
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This search produces a small table that looks kinda like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Description     Registry    numviewed
Billing Invoice     dotblah     3
Daily Auto Renewals dotblah     3
Billing Text        dotblah     14
Annual Report       dotblah     10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I'm trying to do is create a percentage based on the numviewed values and a number displayed in a field.  The field is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;actualcount     424
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So I want to basically have a percent column showing the percent.  So 3 out of 424 would be how many percent?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Description     Registry    numviewed  actualcount  percent
Billing Invoice     dotblah     3       424 
Daily Auto Renewals dotblah     3       424
Billing Text        dotblah     14      424
Annual Report       dotblah     10      424
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried using eval at the end of this but it didn't do anything and showed no results:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="EPPWEB" source="/opt/log/dotblah/web_server/info.log" OR source="/opt/log/dotblah/*/web_server/info.log" WAT | search description="*" | dedup registrar | stats count(registrar) as numviewed by description,registry | eval percent=(numviewed/registrycount)*100
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How can i get the percentage I want?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Sep 2012 21:57:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-Percentage/m-p/69063#M17346</guid>
      <dc:creator>gnovak</dc:creator>
      <dc:date>2012-09-24T21:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-Percentage/m-p/69064#M17347</link>
      <description>&lt;P&gt;Where does actualcount  come from - can you calculate it - if so how ? post the search that gives you the value of actualcount&lt;/P&gt;</description>
      <pubDate>Tue, 25 Sep 2012 09:45:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-Percentage/m-p/69064#M17347</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2012-09-25T09:45:13Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-Percentage/m-p/69065#M17348</link>
      <description>&lt;P&gt;actualcount is a static value that is currently in a lookup file&lt;/P&gt;</description>
      <pubDate>Tue, 25 Sep 2012 14:03:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-Percentage/m-p/69065#M17348</guid>
      <dc:creator>gnovak</dc:creator>
      <dc:date>2012-09-25T14:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-Percentage/m-p/69066#M17349</link>
      <description>&lt;P&gt;First make sure you have the &lt;CODE&gt;count&lt;/CODE&gt; value in a field, so you can include it in &lt;CODE&gt;eval&lt;/CODE&gt;'s calculations. By using &lt;CODE&gt;eventstats&lt;/CODE&gt; you can do this without losing information that is needed later on in the search pipeline. Then do the &lt;CODE&gt;eval&lt;/CODE&gt; stuff inline in your &lt;CODE&gt;stats&lt;/CODE&gt; command. Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="EPPWEB" source="/opt/log/dotblah/web_server/info.log" OR source="/opt/log/dotblah/*/web_server/info.log" WAT search description="*" | dedup registrar | eventstats count by description,registry | stats sum(count) as numviewed,sum(eval(100*numviewed/actualcount)) as percent by description,registry
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Sep 2012 14:21:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-Percentage/m-p/69066#M17349</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-09-25T14:21:26Z</dc:date>
    </item>
  </channel>
</rss>

