<?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 combine unique values of the field into one? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-unique-values-of-the-field-into-one/m-p/410677#M167840</link>
    <description>&lt;P&gt;I am trying to make a report with the unique combination of ID, AVER SRV &amp;amp; ZONE. However, since I am getting lots of duplicate values because I have multiple values for ZONE, is there anyway I can combine all the ZONE in one field so I won't have lots of duplication. &lt;/P&gt;

&lt;P&gt;Currently I am using following query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| dedup ID AVER SRV ZONE | fields + ID, SRV, ZONE
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now if the Zone has multiple values, I am getting multiple entries instead I am trying to have one entry with all the different zones combined.&lt;/P&gt;

&lt;P&gt;Please advise.&lt;/P&gt;</description>
    <pubDate>Thu, 16 Aug 2018 15:44:07 GMT</pubDate>
    <dc:creator>srizan</dc:creator>
    <dc:date>2018-08-16T15:44:07Z</dc:date>
    <item>
      <title>How to combine unique values of the field into one?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-unique-values-of-the-field-into-one/m-p/410677#M167840</link>
      <description>&lt;P&gt;I am trying to make a report with the unique combination of ID, AVER SRV &amp;amp; ZONE. However, since I am getting lots of duplicate values because I have multiple values for ZONE, is there anyway I can combine all the ZONE in one field so I won't have lots of duplication. &lt;/P&gt;

&lt;P&gt;Currently I am using following query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| dedup ID AVER SRV ZONE | fields + ID, SRV, ZONE
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now if the Zone has multiple values, I am getting multiple entries instead I am trying to have one entry with all the different zones combined.&lt;/P&gt;

&lt;P&gt;Please advise.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 15:44:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-unique-values-of-the-field-into-one/m-p/410677#M167840</guid>
      <dc:creator>srizan</dc:creator>
      <dc:date>2018-08-16T15:44:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine unique values of the field into one?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-unique-values-of-the-field-into-one/m-p/410678#M167841</link>
      <description>&lt;P&gt;@srizan&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;... | stats values(*) as * by ID&lt;/CODE&gt; or whatever it is you want to group lines by&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 16:17:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-unique-values-of-the-field-into-one/m-p/410678#M167841</guid>
      <dc:creator>marycordova</dc:creator>
      <dc:date>2018-08-16T16:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine unique values of the field into one?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-unique-values-of-the-field-into-one/m-p/410679#M167842</link>
      <description>&lt;P&gt;@marycordovacaa I apoligize for not being clear, &lt;BR /&gt;
I have various values for ZONE and dedup for &lt;BR /&gt;
&lt;STRONG&gt;ID     | AVER   | SRV  | ZONE&lt;/STRONG&gt;&lt;BR /&gt;
123          1            2          01&lt;BR /&gt;
123          1            2          02&lt;BR /&gt;
123          1            2          03&lt;/P&gt;

&lt;P&gt;I want it to have it something like this&lt;BR /&gt;
&lt;STRONG&gt;ID     | AVER   | SRV  | ZONE&lt;/STRONG&gt;&lt;BR /&gt;
123          1            2          01,02,03&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 16:38:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-unique-values-of-the-field-into-one/m-p/410679#M167842</guid>
      <dc:creator>srizan</dc:creator>
      <dc:date>2018-08-16T16:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine unique values of the field into one?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-unique-values-of-the-field-into-one/m-p/410680#M167843</link>
      <description>&lt;P&gt;@srizan, try the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourCurrentSearch&amp;gt;
| stats values(ZONE) as ZONE by ID AVER SRV
| nomv ZONE
| eval ZONE=replace(ZONE,"\s",",")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following is a run anywhere example based on sample data provided. The query from &lt;CODE&gt;| makeresults&lt;/CODE&gt; till &lt;CODE&gt;| table&lt;/CODE&gt; generates dummy data as per the first table provided in comment.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval data="123 1 2 01;123 1 2 02;123 1 2 03" 
| makemv data delim=";" 
| mvexpand data 
| makemv data delim=" " 
| eval ID=mvindex(data,0),AVER=mvindex(data,1),SRV=mvindex(data,2),ZONE=mvindex(data,3)
| table ID AVER SRV ZONE
| stats values(ZONE) as ZONE by ID AVER SRV
| nomv ZONE
| eval ZONE=replace(ZONE,"\s",",")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Aug 2018 17:02:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-unique-values-of-the-field-into-one/m-p/410680#M167843</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-08-16T17:02:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine unique values of the field into one?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-unique-values-of-the-field-into-one/m-p/410681#M167844</link>
      <description>&lt;P&gt;That worked like a charm, Thank you @niketnilay &lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 17:07:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-unique-values-of-the-field-into-one/m-p/410681#M167844</guid>
      <dc:creator>srizan</dc:creator>
      <dc:date>2018-08-16T17:07:21Z</dc:date>
    </item>
  </channel>
</rss>

