<?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: deduping one field by another field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/deduping-one-field-by-another-field/m-p/231793#M68756</link>
    <description>&lt;P&gt;Hi ajdyer2000,&lt;/P&gt;

&lt;P&gt;you can try &lt;CODE&gt;stats&lt;/CODE&gt; and the &lt;CODE&gt;values()&lt;/CODE&gt; option:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search here | stats count values(server_name) AS server_name BY userid | fields - count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps to get you started ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
    <pubDate>Sat, 19 Sep 2015 19:20:14 GMT</pubDate>
    <dc:creator>MuS</dc:creator>
    <dc:date>2015-09-19T19:20:14Z</dc:date>
    <item>
      <title>deduping one field by another field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/deduping-one-field-by-another-field/m-p/231792#M68755</link>
      <description>&lt;P&gt;Hi &lt;/P&gt;

&lt;P&gt;I'm very new to Splunk so hopefully this is an easy one.&lt;/P&gt;

&lt;P&gt;I have 2 Fields server_name and userid. I would like to remove duplicates from the "userid"  field while keeping the values of "server_name"&lt;/P&gt;

&lt;P&gt;for example&lt;/P&gt;

&lt;P&gt;Search results&lt;/P&gt;

&lt;P&gt;server1, user1&lt;BR /&gt;
server1, user2&lt;BR /&gt;
server1, user2&lt;BR /&gt;
server1, user3&lt;BR /&gt;
server1, user4&lt;BR /&gt;
server2, user1&lt;BR /&gt;
server2, user1&lt;BR /&gt;
server2, user1&lt;BR /&gt;
server2  user2&lt;BR /&gt;
server2, user3&lt;BR /&gt;
server2, user4&lt;BR /&gt;
server2, user4&lt;/P&gt;

&lt;P&gt;What I would like the results to be:&lt;/P&gt;

&lt;P&gt;server1, user1&lt;BR /&gt;
server1, user2&lt;BR /&gt;
server1, user3&lt;BR /&gt;
server1, user4&lt;BR /&gt;
server2, user1&lt;BR /&gt;
server2  user2&lt;BR /&gt;
server2, user3&lt;BR /&gt;
server2, user4&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 07:18:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/deduping-one-field-by-another-field/m-p/231792#M68755</guid>
      <dc:creator>ajdyer2000</dc:creator>
      <dc:date>2020-09-29T07:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: deduping one field by another field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/deduping-one-field-by-another-field/m-p/231793#M68756</link>
      <description>&lt;P&gt;Hi ajdyer2000,&lt;/P&gt;

&lt;P&gt;you can try &lt;CODE&gt;stats&lt;/CODE&gt; and the &lt;CODE&gt;values()&lt;/CODE&gt; option:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search here | stats count values(server_name) AS server_name BY userid | fields - count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps to get you started ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Sat, 19 Sep 2015 19:20:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/deduping-one-field-by-another-field/m-p/231793#M68756</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-09-19T19:20:14Z</dc:date>
    </item>
    <item>
      <title>Re: deduping one field by another field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/deduping-one-field-by-another-field/m-p/231794#M68757</link>
      <description>&lt;P&gt;Looking at your results, actually you should know that &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.6/SearchReference/dedup"&gt;dedup&lt;/A&gt; can take multiple fields in which case you wind up with all unique sets of fields:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search | dedup server_name, userid
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;To try this out you could mock up your example data, with a base search like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| noop | stats count | eval raw = split("server1,user1;server1,user2;server1,user2;server1,user3;server1,user4;server2,user1;server2,user1;server2,user1;server2,user2;server2,user3;server2,user4;server2,user4",";") | mvexpand raw | eval server=mvindex(split(raw,","),0) | eval user=mvindex(split(raw,","),1) | fields server,user
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then compare the result to:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| noop | stats count | eval raw = split("server1,user1;server1,user2;server1,user2;server1,user3;server1,user4;server2,user1;server2,user1;server2,user1;server2,user2;server2,user3;server2,user4;server2,user4",";") | mvexpand raw | eval server=mvindex(split(raw,","),0) | eval user=mvindex(split(raw,","),1) | fields server,user | dedup server_name, userid
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 19 Sep 2015 19:37:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/deduping-one-field-by-another-field/m-p/231794#M68757</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2015-09-19T19:37:41Z</dc:date>
    </item>
  </channel>
</rss>

