<?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 How to achieve distinct count across multiple fields? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-distinct-count-across-multiple-fields/m-p/85058#M182102</link>
    <description>&lt;P&gt;How to get a distinct count across two different fields. I have webserver request logs containing browser family and IP address – so should be able to get a count of different &amp;amp; distinct user-browsers by browser family – i.e. how many different users are using Safari for example. But piping into:&lt;/P&gt;
&lt;P&gt;stats dc(ua_family,cp_ip) by ua_family&lt;/P&gt;
&lt;P&gt;… doesn’t do it - I get a distinct list of browser families but zero counts. But concatenating the fields:&lt;/P&gt;
&lt;P&gt;eval comb=c_ip.ua_family | stats dc(comb) by ua_family&lt;/P&gt;
&lt;P&gt;…does work. Is there a way to do it without concatenating?&lt;BR /&gt;So why didn’t the dc on the two separate fields work?&lt;/P&gt;</description>
    <pubDate>Thu, 15 Jun 2023 21:46:21 GMT</pubDate>
    <dc:creator>robert2138</dc:creator>
    <dc:date>2023-06-15T21:46:21Z</dc:date>
    <item>
      <title>How to achieve distinct count across multiple fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-distinct-count-across-multiple-fields/m-p/85058#M182102</link>
      <description>&lt;P&gt;How to get a distinct count across two different fields. I have webserver request logs containing browser family and IP address – so should be able to get a count of different &amp;amp; distinct user-browsers by browser family – i.e. how many different users are using Safari for example. But piping into:&lt;/P&gt;
&lt;P&gt;stats dc(ua_family,cp_ip) by ua_family&lt;/P&gt;
&lt;P&gt;… doesn’t do it - I get a distinct list of browser families but zero counts. But concatenating the fields:&lt;/P&gt;
&lt;P&gt;eval comb=c_ip.ua_family | stats dc(comb) by ua_family&lt;/P&gt;
&lt;P&gt;…does work. Is there a way to do it without concatenating?&lt;BR /&gt;So why didn’t the dc on the two separate fields work?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 21:46:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-distinct-count-across-multiple-fields/m-p/85058#M182102</guid>
      <dc:creator>robert2138</dc:creator>
      <dc:date>2023-06-15T21:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct count across multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-distinct-count-across-multiple-fields/m-p/85059#M182103</link>
      <description>&lt;P&gt;May be dc doesn't work on multiple fields..&lt;/P&gt;

&lt;P&gt;you can get it like this:&lt;BR /&gt;
| stats distinct_count(ua_family) ua_ip dd by ua_family,cp_ip|stats count(ua_ip)&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:15:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-distinct-count-across-multiple-fields/m-p/85059#M182103</guid>
      <dc:creator>linu1988</dc:creator>
      <dc:date>2020-09-28T14:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct count across multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-distinct-count-across-multiple-fields/m-p/85060#M182104</link>
      <description>&lt;P&gt;i am not actually sure what you are asking to count, but either &lt;CODE&gt;... | stats dc(c_ip) by ua_family&lt;/CODE&gt; or &lt;CODE&gt;... | stats count by ua_family,c_ip&lt;/CODE&gt; may be what you want. if not, perhaps you could clarify as i don't think i understand what you're looking for.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jul 2013 19:49:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-distinct-count-across-multiple-fields/m-p/85060#M182104</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2013-07-04T19:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct count across multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-distinct-count-across-multiple-fields/m-p/85061#M182105</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;

&lt;P&gt;You could use dedup to get only 1 event per combination of user agent and ip and then make a regular count:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | dedup ua_family cp_ip | stats count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jul 2013 06:55:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-distinct-count-across-multiple-fields/m-p/85061#M182105</guid>
      <dc:creator>gfuente</dc:creator>
      <dc:date>2013-07-05T06:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct count across multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-distinct-count-across-multiple-fields/m-p/85062#M182106</link>
      <description>&lt;P&gt;Not sure if it helps but in my case, I have some stats that require me to look at combination of clients services, and the intersection (some clients are using some services, but not others). I needed to do some stats for distinct client, service, and the client-service contracts.  My raw data already have the field of each transaction with name of the client and service they have.  I can get that by creating a new field, CONTRACT, which is simply a concatenation of client and service, then I can do a distinct count on it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count by CLIENT SERVICE | eval CONTRACT = CLIENT . "-" . SERVICE | stats dc(SERVICE) dc(CLIENT) dc(CONTRACT)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Sep 2016 11:33:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-distinct-count-across-multiple-fields/m-p/85062#M182106</guid>
      <dc:creator>weezeee</dc:creator>
      <dc:date>2016-09-28T11:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct count across multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-distinct-count-across-multiple-fields/m-p/85063#M182107</link>
      <description>&lt;P&gt;Credit goes to @micahkemp:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats dc(eval(mvappend(field1, field2, field3)))
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Jan 2020 23:39:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-distinct-count-across-multiple-fields/m-p/85063#M182107</guid>
      <dc:creator>nick405060</dc:creator>
      <dc:date>2020-01-23T23:39:53Z</dc:date>
    </item>
  </channel>
</rss>

