<?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: addtotals to calculate percentage in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/addtotals-to-calculate-percentage/m-p/314104#M94020</link>
    <description>&lt;P&gt;Filter for the OS of choice &lt;STRONG&gt;after&lt;/STRONG&gt; evaluating the percentages.&lt;/P&gt;</description>
    <pubDate>Tue, 23 Jan 2018 09:25:40 GMT</pubDate>
    <dc:creator>FrankVl</dc:creator>
    <dc:date>2018-01-23T09:25:40Z</dc:date>
    <item>
      <title>addtotals to calculate percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/addtotals-to-calculate-percentage/m-p/314094#M94010</link>
      <description>&lt;P&gt;I am trying to calculate what percentage of Operating Systems have windows 10 installed out of the total number which in this example is 174. &lt;/P&gt;

&lt;P&gt;I have used a table as the easiest way to try and achieve this but ideally I want to display the final values as a single value. However, any solution would be really useful now.&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/4177i29FD3EE18987D5D8/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;PRE&gt;&lt;CODE&gt;`GEN_ProductionWorkstations` 
| join type=left machine 
    [ search index=ad source=otl_addnsscan 
    | eval machine=lower(name)] 
| rename User_Name0 as LastKnownUser, Caption0 as operatingSystem, Version0 as Version, Model0 as Model 
| rename data as IPAddress 
| search machine="*" 
| dedup machine 
| stats count(machine) by operatingSystem 
| addtotals col=t labelfield=totalOSCount label="osCount" fieldname="total" 
| fillnull value="Total Client Estate" operatingSystem
| fields- count(machine) Product totalOSCount
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Jan 2018 15:58:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/addtotals-to-calculate-percentage/m-p/314094#M94010</guid>
      <dc:creator>davidcraven02</dc:creator>
      <dc:date>2018-01-22T15:58:13Z</dc:date>
    </item>
    <item>
      <title>Re: addtotals to calculate percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/addtotals-to-calculate-percentage/m-p/314095#M94011</link>
      <description>&lt;P&gt;I usually do that with a combination of eventstats (to add the total to each row) and eval (to divide row count by totals to get the percentage):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventstats sum(count) as totals
| eval percentage=100*count/totals
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Jan 2018 16:16:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/addtotals-to-calculate-percentage/m-p/314095#M94011</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-01-22T16:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: addtotals to calculate percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/addtotals-to-calculate-percentage/m-p/314096#M94012</link>
      <description>&lt;P&gt;Thanks. How do I build this into my search?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 16:21:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/addtotals-to-calculate-percentage/m-p/314096#M94012</guid>
      <dc:creator>davidcraven02</dc:creator>
      <dc:date>2018-01-22T16:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: addtotals to calculate percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/addtotals-to-calculate-percentage/m-p/314097#M94013</link>
      <description>&lt;P&gt;Add it after line 9 and adjust the field names to match what you have / want and see which bits of lines 10-12 you still need.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 16:32:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/addtotals-to-calculate-percentage/m-p/314097#M94013</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-01-22T16:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: addtotals to calculate percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/addtotals-to-calculate-percentage/m-p/314098#M94014</link>
      <description>&lt;P&gt;Hi @davidcraven02,&lt;BR /&gt;
Try below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; `GEN_ProductionWorkstations` 
 | join type=left machine 
     [ search index=ad source=otl_addnsscan 
     | eval machine=lower(name)] 
 | rename User_Name0 as LastKnownUser, Caption0 as operatingSystem, Version0 as Version, Model0 as Model 
 | rename data as IPAddress 
 | search machine="*" 
 | dedup machine 
 | stats count(machine) as count by operatingSystem 
 | eventstats sum(count) as total
| eval percentage = ((count/total)*100)
|eval percentage =percentage ."%"
|table operatingSystem , count , percentage 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Jan 2018 17:04:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/addtotals-to-calculate-percentage/m-p/314098#M94014</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-01-22T17:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: addtotals to calculate percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/addtotals-to-calculate-percentage/m-p/314099#M94015</link>
      <description>&lt;P&gt;I think your requirement is something like this, also you need to customize your query some this commands have no useful purpose so you can just avoid that..&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; `GEN_ProductionWorkstations` 
 | join type=left machine 
     [ search index=ad source=otl_addnsscan 
     | eval machine=lower(name)] 
 | rename User_Name0 as LastKnownUser, Caption0 as operatingSystem, Version0 as Version, Model0 as Model 
 | rename data as IPAddress 
 | search machine="*" 
 | dedup machine 
 | stats count(machine) as count by operatingSystem 
 | eventstats sum(count) as total_count
 |eval percentage=round(100*count/total_count,2)
| addcoltotals labelfield=operatingSystem  label=Total Client Estate"
 | fields- total_count 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;let me know if this helps!&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 17:16:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/addtotals-to-calculate-percentage/m-p/314099#M94015</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-22T17:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: addtotals to calculate percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/addtotals-to-calculate-percentage/m-p/314100#M94016</link>
      <description>&lt;P&gt;This offers a slight different solution which also works! Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 07:48:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/addtotals-to-calculate-percentage/m-p/314100#M94016</guid>
      <dc:creator>davidcraven02</dc:creator>
      <dc:date>2018-01-23T07:48:46Z</dc:date>
    </item>
    <item>
      <title>Re: addtotals to calculate percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/addtotals-to-calculate-percentage/m-p/314101#M94017</link>
      <description>&lt;P&gt;Thanks this works! How could this be tweaked to be used as a single value display to show the '% of OS's on Windows 10' for example. When I include  the below it calculates it as 100% as the other OS's have been removed from the table.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | search machine="*" operatingSystem="*10*"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any ideas? &lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 07:51:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/addtotals-to-calculate-percentage/m-p/314101#M94017</guid>
      <dc:creator>davidcraven02</dc:creator>
      <dc:date>2018-01-23T07:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: addtotals to calculate percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/addtotals-to-calculate-percentage/m-p/314102#M94018</link>
      <description>&lt;P&gt;have you tried to run this search at last of whole query?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 07:58:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/addtotals-to-calculate-percentage/m-p/314102#M94018</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-01-23T07:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: addtotals to calculate percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/addtotals-to-calculate-percentage/m-p/314103#M94019</link>
      <description>&lt;P&gt;Yes. In a table format it works correct. But I want to display is as a single value i.e 80% which reflects the percentage of a particular OS. &lt;/P&gt;

&lt;P&gt;I have tried the below, but it only works if Windows 10 is listed first in this table which make sit not reliable.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;`GEN_ProductionWorkstations` 
  | join type=left machine 
      [ search index=ad source=otl_addnsscan 
      | eval machine=lower(name)] 
  | rename User_Name0 as LastKnownUser, Caption0 as operatingSystem, Version0 as Version, Model0 as Model 
  | rename data as IPAddress 
  | search $companyCode$ operatingSystem="*" OR NOT operatingSystem="*" 
  | fillnull value="No OS listed" operatingSystem
  | dedup machine 
  | stats count(machine) as count by operatingSystem 
  | eventstats sum(count) as total
 | eval percentage = ((count/total)*100)
 | eval percentage = round(percentage,2)
 |eval percentage =percentage ."%"
 |table percentage, operatingSystem , count , 
 |sort operatingSystem
 | fields-  count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Jan 2018 09:10:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/addtotals-to-calculate-percentage/m-p/314103#M94019</guid>
      <dc:creator>davidcraven02</dc:creator>
      <dc:date>2018-01-23T09:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: addtotals to calculate percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/addtotals-to-calculate-percentage/m-p/314104#M94020</link>
      <description>&lt;P&gt;Filter for the OS of choice &lt;STRONG&gt;after&lt;/STRONG&gt; evaluating the percentages.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 09:25:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/addtotals-to-calculate-percentage/m-p/314104#M94020</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-01-23T09:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: addtotals to calculate percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/addtotals-to-calculate-percentage/m-p/314105#M94021</link>
      <description>&lt;P&gt;yes as @FrankVl suggested &lt;CODE&gt;| search $companyCode$ operatingSystem="*" OR NOT operatingSystem="*"&lt;/CODE&gt; should be after percentage evaluation&lt;BR /&gt;
Try below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; `GEN_ProductionWorkstations` 
   | join type=left machine 
       [ search index=ad source=otl_addnsscan 
       | eval machine=lower(name)] 
   | rename User_Name0 as LastKnownUser, Caption0 as operatingSystem, Version0 as Version, Model0 as Model 
   | rename data as IPAddress 
    | fillnull value="No OS listed" operatingSystem
   | dedup machine 
   | stats count(machine) as count by operatingSystem 
   | eventstats sum(count) as total
  | eval percentage = ((count/total)*100)
  | eval percentage = round(percentage,2)
  |eval percentage =percentage ."%"
  | search $companyCode$ operatingSystem="*" OR NOT operatingSystem="*" 
  |table percentage, operatingSystem , count , 
  |sort operatingSystem
  | fields-  count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Jan 2018 09:31:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/addtotals-to-calculate-percentage/m-p/314105#M94021</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-01-23T09:31:19Z</dc:date>
    </item>
  </channel>
</rss>

