<?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/83093#M21129</link>
    <description>&lt;P&gt;Could you paste your complete search, not just the portion starting with the &lt;CODE&gt;count&lt;/CODE&gt;?&lt;/P&gt;</description>
    <pubDate>Mon, 25 Jun 2012 19:11:23 GMT</pubDate>
    <dc:creator>Ayn</dc:creator>
    <dc:date>2012-06-25T19:11:23Z</dc:date>
    <item>
      <title>Calculating Percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/83092#M21128</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;

&lt;P&gt;I'm having trouble with the syntax and function usage... I am trying to have splunk calculate the percentage of completed downloads. I first created two event types called total_downloads and completed; these are saved searches. &lt;/P&gt;

&lt;P&gt;I tried this in the search, but it returned 0 matching fields, which isn't right, my event types are definitely not empty...:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;count(eval(eventtype="total_downloads")) AS total, count(eval(eventtype="completed")) AS complete | eval percent_difference=((total/complete)*100) | table percent_difference
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can anyone help with finding the right command? I'm a little confused with event types and etc.? new to splunk... :&amp;lt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jun 2012 18:44:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/83092#M21128</guid>
      <dc:creator>monicato</dc:creator>
      <dc:date>2012-06-25T18:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/83093#M21129</link>
      <description>&lt;P&gt;Could you paste your complete search, not just the portion starting with the &lt;CODE&gt;count&lt;/CODE&gt;?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jun 2012 19:11:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/83093#M21129</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-06-25T19:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/83094#M21130</link>
      <description>&lt;P&gt;that is the entire search... &amp;gt;.&amp;lt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jun 2012 20:00:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/83094#M21130</guid>
      <dc:creator>monicato</dc:creator>
      <dc:date>2012-06-25T20:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/83095#M21131</link>
      <description>&lt;P&gt;Then that's your problem right there &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jun 2012 20:04:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/83095#M21131</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-06-25T20:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/83096#M21132</link>
      <description>&lt;P&gt;Generally speaking it's always a good idea not to try to build a whole search right away (unless you know well what you're doing), but rather take it one step at a time. In your case the reason you're getting 0 results is that everything before the first pipe character is interpreted by Splunk as being keywords it should search for. So instead of calculating the statistics you want, it will actually search for events having the text "&lt;CODE&gt;count(eval(eventtype="total_downloads"))&lt;/CODE&gt;", "&lt;CODE&gt;AS&lt;/CODE&gt;", "&lt;CODE&gt;total&lt;/CODE&gt;" and so on. What you'll want to do is enter any search terms you might have first of all, then use the &lt;CODE&gt;stats&lt;/CODE&gt; command to get the stats you're halfway through getting in the search you have now. Something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourbasesearch&amp;gt; | stats count(eval(eventtype="total_downloads")) AS total, count(eval(eventtype="completed")) AS complete | eval percent_difference=((total/complete)*100) | table percent_difference
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Jun 2012 20:11:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/83096#M21132</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-06-25T20:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/83097#M21133</link>
      <description>&lt;P&gt;hmm, yeah, I'm not sure what I should put. I tried putting a pipe and a command before count(... but it still doesn't find any matching events...&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jun 2012 20:14:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/83097#M21133</guid>
      <dc:creator>monicato</dc:creator>
      <dc:date>2012-06-25T20:14:24Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/83098#M21134</link>
      <description>&lt;P&gt;ahh i see, thanks for clearing that up... it's taking me a while to understand the search engine : / &lt;/P&gt;

&lt;P&gt;Thank you for the help! it works! : ))&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jun 2012 20:23:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/83098#M21134</guid>
      <dc:creator>monicato</dc:creator>
      <dc:date>2012-06-25T20:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/83099#M21135</link>
      <description>&lt;P&gt;If you want to round it and add the % you can use this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval "percent"=((count/Total)*100) | eval "rounded_percent"=round('percent') | fieldformat "rounded_percent"=tostring('External_%')+"%"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Mar 2017 19:17:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/83099#M21135</guid>
      <dc:creator>ddalling</dc:creator>
      <dc:date>2017-03-03T19:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/83100#M21136</link>
      <description>&lt;P&gt;piggybacking off of this, &lt;/P&gt;

&lt;P&gt;could you timechart the new calculated percentage? &lt;/P&gt;

&lt;P&gt;for example what if you wanted to graph the percentage over time, month over mont etc,  in line chart or area chart?&lt;/P&gt;

&lt;P&gt;could you provide an example &lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2019 18:19:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculating-Percentage/m-p/83100#M21136</guid>
      <dc:creator>michaeltayo</dc:creator>
      <dc:date>2019-09-10T18:19:51Z</dc:date>
    </item>
  </channel>
</rss>

