<?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 Tally field by value and source and divide by total source count in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Tally-field-by-value-and-source-and-divide-by-total-source-count/m-p/467657#M191892</link>
    <description>&lt;P&gt;Hello, all.&lt;/P&gt;

&lt;P&gt;I'm looking for the best method to tally a particular field by value and source and then run division with that tally.&lt;/P&gt;

&lt;P&gt;index=abc sourcetype=csv &lt;BR /&gt;
| eval failpass=if(a!=b,0,1) &lt;BR /&gt;
| stats count by source, failpass | sort source&lt;/P&gt;

&lt;P&gt;Given the above, I'd like to total the failpass=0 by source and the failpass=1 by source, then run division on the total failpass by source. &lt;/P&gt;

&lt;P&gt;So if source abc.csv has 20 total events and 13 of those are failpass=0;  and 7 of them are failpass=1, and def.csv has 10 events with failpass=0 and 10 events with failpass=1, then I'd show&lt;/P&gt;

&lt;P&gt;Source     0     1     div1     div2&lt;BR /&gt;
abc.csv    13    7     .65         .35 &lt;BR /&gt;
def.csv     10    10   .50        .50&lt;/P&gt;

&lt;P&gt;I'm curious if there's a good way to pull that off. &lt;/P&gt;

&lt;P&gt;TIA,&lt;BR /&gt;
Reiger&lt;/P&gt;</description>
    <pubDate>Wed, 04 Sep 2019 01:41:50 GMT</pubDate>
    <dc:creator>reigerourich</dc:creator>
    <dc:date>2019-09-04T01:41:50Z</dc:date>
    <item>
      <title>Tally field by value and source and divide by total source count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Tally-field-by-value-and-source-and-divide-by-total-source-count/m-p/467657#M191892</link>
      <description>&lt;P&gt;Hello, all.&lt;/P&gt;

&lt;P&gt;I'm looking for the best method to tally a particular field by value and source and then run division with that tally.&lt;/P&gt;

&lt;P&gt;index=abc sourcetype=csv &lt;BR /&gt;
| eval failpass=if(a!=b,0,1) &lt;BR /&gt;
| stats count by source, failpass | sort source&lt;/P&gt;

&lt;P&gt;Given the above, I'd like to total the failpass=0 by source and the failpass=1 by source, then run division on the total failpass by source. &lt;/P&gt;

&lt;P&gt;So if source abc.csv has 20 total events and 13 of those are failpass=0;  and 7 of them are failpass=1, and def.csv has 10 events with failpass=0 and 10 events with failpass=1, then I'd show&lt;/P&gt;

&lt;P&gt;Source     0     1     div1     div2&lt;BR /&gt;
abc.csv    13    7     .65         .35 &lt;BR /&gt;
def.csv     10    10   .50        .50&lt;/P&gt;

&lt;P&gt;I'm curious if there's a good way to pull that off. &lt;/P&gt;

&lt;P&gt;TIA,&lt;BR /&gt;
Reiger&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 01:41:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Tally-field-by-value-and-source-and-divide-by-total-source-count/m-p/467657#M191892</guid>
      <dc:creator>reigerourich</dc:creator>
      <dc:date>2019-09-04T01:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: Tally field by value and source and divide by total source count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Tally-field-by-value-and-source-and-divide-by-total-source-count/m-p/467658#M191893</link>
      <description>&lt;P&gt;@reigerourich ,&lt;/P&gt;

&lt;P&gt;Try and test against your data&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=abc sourcetype=csv
| eval failpass=if(a!=b,0,1)
| stats count(eval(failpass==0)) as fail,count(eval(failpass==1)) as pass, count as total by source
| eval div1=fail/total, div2=pass/total
| fields - total
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Sep 2019 07:59:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Tally-field-by-value-and-source-and-divide-by-total-source-count/m-p/467658#M191893</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2019-09-04T07:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: Tally field by value and source and divide by total source count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Tally-field-by-value-and-source-and-divide-by-total-source-count/m-p/467659#M191894</link>
      <description>&lt;P&gt;Thank you, Renjith, that worked perfectly as written!&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 19:45:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Tally-field-by-value-and-source-and-divide-by-total-source-count/m-p/467659#M191894</guid>
      <dc:creator>reigerourich</dc:creator>
      <dc:date>2019-09-04T19:45:07Z</dc:date>
    </item>
  </channel>
</rss>

