<?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: Why does dedup count and dc return a different number of values? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-does-dedup-count-and-dc-return-a-different-number-of-values/m-p/271056#M81596</link>
    <description>&lt;P&gt;This definitely helps @somesoni2! Thank you!&lt;/P&gt;</description>
    <pubDate>Tue, 25 Oct 2016 14:48:47 GMT</pubDate>
    <dc:creator>tmaltizo</dc:creator>
    <dc:date>2016-10-25T14:48:47Z</dc:date>
    <item>
      <title>Why does dedup count and dc return a different number of values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-dedup-count-and-dc-return-a-different-number-of-values/m-p/271052#M81592</link>
      <description>&lt;P&gt;Doing separate searches with &lt;CODE&gt;dc&lt;/CODE&gt; doesn't match numbers returned by a &lt;CODE&gt;dedup count&lt;/CODE&gt;, except for the total. This is for the "&lt;STRONG&gt;All time&lt;/STRONG&gt;" time frame. But, the issue prevails regardless of the time frame.&lt;/P&gt;

&lt;P&gt;=====================================================&lt;/P&gt;

&lt;P&gt;Using &lt;STRONG&gt;dc&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;index="forescout" sourcetype="fs_av_compliance" description="Server*" &lt;STRONG&gt;status="compliant"&lt;/STRONG&gt; | stats dc(src_ip)&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;2804&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;index="forescout" sourcetype="fs_av_compliance" description="Server*" &lt;STRONG&gt;status="non-compliant"&lt;/STRONG&gt; | stats dc(src_ip)&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;614&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;index="forescout" sourcetype="fs_av_compliance" description="Server*"| stats dc(src_ip)&lt;/P&gt;

&lt;P&gt;2922&lt;/P&gt;

&lt;P&gt;=====================================================&lt;/P&gt;

&lt;P&gt;Using &lt;STRONG&gt;count&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;index="forescout" sourcetype="fs_av_compliance" description="Server*" | dedup src_ip | stats count by status | addcoltotals&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;compliant = 2767&lt;/STRONG&gt;&lt;BR /&gt;
&lt;STRONG&gt;non-compliant = 155&lt;/STRONG&gt;&lt;BR /&gt;
addcoltotals = 2922&lt;/P&gt;

&lt;P&gt;Any insight is much appreciated!&lt;BR /&gt;
Trista&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:32:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-dedup-count-and-dc-return-a-different-number-of-values/m-p/271052#M81592</guid>
      <dc:creator>tmaltizo</dc:creator>
      <dc:date>2020-09-29T11:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: Why does dedup count and dc return a different number of values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-dedup-count-and-dc-return-a-different-number-of-values/m-p/271053#M81593</link>
      <description>&lt;P&gt;Here's an example&lt;/P&gt;

&lt;P&gt;_time=1 index=forescout ip=x.x.x.x status=complaint&lt;BR /&gt;
_time=2 index=forescout ip=x.x.x.x status=complaint&lt;BR /&gt;
_time=3 index=forescout ip=x.x.x.x status=non-complaint&lt;/P&gt;

&lt;P&gt;With the above sample data &lt;CODE&gt;dc(ip)&lt;/CODE&gt; will return 1 for compliant and 1 for non-compliant, Whereas &lt;CODE&gt;dedup ip | stats count by ip&lt;/CODE&gt; will return only one for compliant. &lt;/P&gt;

&lt;P&gt;For a more appropriate comparison try 'dedup ip status | stats count by status | addtotals`&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2016 21:53:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-dedup-count-and-dc-return-a-different-number-of-values/m-p/271053#M81593</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-10-24T21:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: Why does dedup count and dc return a different number of values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-dedup-count-and-dc-return-a-different-number-of-values/m-p/271054#M81594</link>
      <description>&lt;P&gt;Suppose your data set is this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;src_ip  status
--------------------
src1    Compliance
src1    Compliance
src2    Non-compliance
src1    Non-compliance
src2    Compliance
src3    Compliance
src4    Non-compliance
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Output of query 1 (distinct count of src_ip where status =Compliance) is 3 (src1, src2 and src3)&lt;BR /&gt;
Output of query 2 (distinct count of src_ip where status =Non-compliance) is 3 (src2, src1 and src4)&lt;BR /&gt;
Output of query 3 (distinct count of src_ip regardless of status) is 4 (src1,src2,src3 and src4)&lt;/P&gt;

&lt;P&gt;This will be the output of query 4 after you run till dedup src_ip (take the first events for each src_ip)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;src_ip  status
-----------
src1    Compliance
src2    Non-compliance
src3    Compliance
src4    Non-compliance
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So, the count of src_ip with status=Compliance is now 2, &lt;BR /&gt;
So, the count of src_ip with status=Non-compliance is now 2, &lt;BR /&gt;
And total count is still 4 as there are still 4 distinct src_ip.&lt;/P&gt;

&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:35:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-dedup-count-and-dc-return-a-different-number-of-values/m-p/271054#M81594</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-29T11:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: Why does dedup count and dc return a different number of values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-dedup-count-and-dc-return-a-different-number-of-values/m-p/271055#M81595</link>
      <description>&lt;P&gt;Thanks for the clarification @sundareshr!&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2016 14:48:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-dedup-count-and-dc-return-a-different-number-of-values/m-p/271055#M81595</guid>
      <dc:creator>tmaltizo</dc:creator>
      <dc:date>2016-10-25T14:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: Why does dedup count and dc return a different number of values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-dedup-count-and-dc-return-a-different-number-of-values/m-p/271056#M81596</link>
      <description>&lt;P&gt;This definitely helps @somesoni2! Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2016 14:48:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-dedup-count-and-dc-return-a-different-number-of-values/m-p/271056#M81596</guid>
      <dc:creator>tmaltizo</dc:creator>
      <dc:date>2016-10-25T14:48:47Z</dc:date>
    </item>
    <item>
      <title>Re: Why does dedup count and dc return a different number of values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-dedup-count-and-dc-return-a-different-number-of-values/m-p/271057#M81597</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/140181"&gt;@sundareshr&lt;/a&gt;,&lt;/P&gt;

&lt;P&gt;If dc counts each unique ip/status and dedup counts only the first instance, then why are the totals the same?&lt;/P&gt;

&lt;P&gt;... | dedup src_ip  | stats count(src_ip) = 2928&lt;BR /&gt;
... | stats dc(src_ip) = 2928&lt;/P&gt;

&lt;P&gt;When I run the following....&lt;BR /&gt;
... | dedup src_ip status | stats count by status | addtotals&lt;/P&gt;

&lt;P&gt;compliant = 2809, total=2809&lt;BR /&gt;
non-compliant = 616, total=616&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:33:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-dedup-count-and-dc-return-a-different-number-of-values/m-p/271057#M81597</guid>
      <dc:creator>tmaltizo</dc:creator>
      <dc:date>2020-09-29T11:33:04Z</dc:date>
    </item>
  </channel>
</rss>

