<?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: Count Fraction of Distinct events in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Count-Fraction-of-Distinct-events/m-p/247812#M73933</link>
    <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search giving fields CountryId FooId BarId | eval FooBarEqual=if(FooId=BarId,1,0)
| stats count as total sum(FooBarEqual) as FooBarEqual by CountryId | eval FoolBarEqual=FooBarEqual/total
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 14 Oct 2016 21:00:06 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2016-10-14T21:00:06Z</dc:date>
    <item>
      <title>Count Fraction of Distinct events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-Fraction-of-Distinct-events/m-p/247811#M73932</link>
      <description>&lt;P&gt;I woudl like to know, per CountryId, what fraction of FooId equal to BarId&lt;/P&gt;

&lt;P&gt;In the follwoing log:&lt;/P&gt;

&lt;P&gt;MyEvent CountryId=1 FooId=63407020 BarId=82955997&lt;BR /&gt;
MyEvent CountryId=1 FooId=63407020 BarId=63407020&lt;BR /&gt;
MyEvent CountryId=2 FooId=65407020 BarId=207020&lt;/P&gt;

&lt;P&gt;So the desired output would be:&lt;/P&gt;

&lt;P&gt;CountryId=1 1/2&lt;BR /&gt;
CountryId=2 0&lt;/P&gt;

&lt;P&gt;In pseudo-Splunk Search this would look something along the lines of:&lt;BR /&gt;
((count(MyEvent) | where FooId != BarId) / count(MyEvent)) by CountryId&lt;/P&gt;

&lt;P&gt;But how would I write this query in actual Splunk syntax?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2016 14:23:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-Fraction-of-Distinct-events/m-p/247811#M73932</guid>
      <dc:creator>viggor</dc:creator>
      <dc:date>2016-10-14T14:23:20Z</dc:date>
    </item>
    <item>
      <title>Re: Count Fraction of Distinct events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-Fraction-of-Distinct-events/m-p/247812#M73933</link>
      <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search giving fields CountryId FooId BarId | eval FooBarEqual=if(FooId=BarId,1,0)
| stats count as total sum(FooBarEqual) as FooBarEqual by CountryId | eval FoolBarEqual=FooBarEqual/total
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Oct 2016 21:00:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-Fraction-of-Distinct-events/m-p/247812#M73933</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-10-14T21:00:06Z</dc:date>
    </item>
  </channel>
</rss>

