<?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: Convert Multiple Values in single field to multiple fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Convert-Multiple-Values-in-single-field-to-multiple-fields/m-p/353692#M104683</link>
    <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval Datacenter="FHD (1) | TDC (3) | SDC (2)"
| streamstats count AS _serial

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| makemv Delim=" | " Datacenter
| mvexpand Datacenter
| rex field=Datacenter "^(?&amp;lt;Key&amp;gt;\S+)\s+\((?&amp;lt;Value&amp;gt;.*)\)$"
| eval Datacenter_{Key} = Value
| fields - Datacenter Key Value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;At this point you should do your filtering logic on the new fields and if you need to merge back, you can add this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats values(*) AS * BY _serial
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 07 Aug 2017 22:57:31 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2017-08-07T22:57:31Z</dc:date>
    <item>
      <title>Convert Multiple Values in single field to multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-Multiple-Values-in-single-field-to-multiple-fields/m-p/353687#M104678</link>
      <description>&lt;P&gt;I am needing some assistance with the following issue with a field with multiple Values.&lt;BR /&gt;
Since this is coming from a database input I am having some issues trying to get this fixed.&lt;/P&gt;

&lt;P&gt;I have a field that looks like this:&lt;BR /&gt;
Datacenter=FHD (1) | TDC (1) | SDC (1)&lt;/P&gt;

&lt;P&gt;I cannot do any functions with this since they show up as text.&lt;/P&gt;

&lt;P&gt;Is there a way I can break out the Datacenter values to individual Fields to look like below.  Or at the very least be able to calculate the numbers inside the "()"&lt;/P&gt;

&lt;P&gt;Datacenter_FHD=1&lt;BR /&gt;
Datacenter_TDC=1&lt;BR /&gt;
Datacenter_SDC=1&lt;/P&gt;

&lt;P&gt;Thanks for any help on this.&lt;BR /&gt;
matt4321&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:15:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-Multiple-Values-in-single-field-to-multiple-fields/m-p/353687#M104678</guid>
      <dc:creator>matt4321</dc:creator>
      <dc:date>2020-09-29T15:15:34Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Multiple Values in single field to multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-Multiple-Values-in-single-field-to-multiple-fields/m-p/353688#M104679</link>
      <description>&lt;P&gt;you could write a regex statement to break it out:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|rex field=fieldName "FHD\s\((?&amp;lt;DC_FHD&amp;gt;\d+).*TDC\s\((?&amp;lt;DC_TDC&amp;gt;\d+).*SDC\s\((?&amp;lt;DC_SDC&amp;gt;\d+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;that should get you three field names with the values inside parens. &lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 15:55:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-Multiple-Values-in-single-field-to-multiple-fields/m-p/353688#M104679</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-08-07T15:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Multiple Values in single field to multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-Multiple-Values-in-single-field-to-multiple-fields/m-p/353689#M104680</link>
      <description>&lt;P&gt;@matt4321, you can try the following run anywhere search to come up with the query/regular expression you need.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval Datacenter="FHD (1) | TDC (1) | SDC (1)"
| eval Datacenter=trim(split(Datacenter,"|"))
| mvexpand Datacenter
| rex field=Datacenter "(?&amp;lt;Name&amp;gt;[^\(]+)\((?&amp;lt;Count&amp;gt;[^\)]+)\)"
| eval Name="Datacenter_".Name
| table Name Count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;First two pipes are used to mimic the data as per your example. &lt;CODE&gt;split()&lt;/CODE&gt; function is used to create multivalue field based on pipe separator &lt;CODE&gt;(|)&lt;/CODE&gt;. The &lt;CODE&gt;mvexpand&lt;/CODE&gt; command is used to create three single value fields. Finally, &lt;CODE&gt;rex&lt;/CODE&gt;field is used to extract the field name and value using regular expression as &lt;CODE&gt;Name&lt;/CODE&gt; and &lt;CODE&gt;Count&lt;/CODE&gt; respectively.&lt;BR /&gt;
Your actual regular expression may change based on the data. Please test and change accordingly. You can use regex101.com to validate the same.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 15:57:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-Multiple-Values-in-single-field-to-multiple-fields/m-p/353689#M104680</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-08-07T15:57:55Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Multiple Values in single field to multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-Multiple-Values-in-single-field-to-multiple-fields/m-p/353690#M104681</link>
      <description>&lt;P&gt;Are the values fixed?  If yes, will they always available in the same order?&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 15:58:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-Multiple-Values-in-single-field-to-multiple-fields/m-p/353690#M104681</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-08-07T15:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Multiple Values in single field to multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-Multiple-Values-in-single-field-to-multiple-fields/m-p/353691#M104682</link>
      <description>&lt;P&gt;Unfortunately no.. there are even some other values that are in other events in the Datacenter field.  I would love to be able to build a dynamic search on these.  Also I have one other similar field that has multiple values formatted similarly but with Status values.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 16:11:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-Multiple-Values-in-single-field-to-multiple-fields/m-p/353691#M104682</guid>
      <dc:creator>matt4321</dc:creator>
      <dc:date>2017-08-07T16:11:58Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Multiple Values in single field to multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-Multiple-Values-in-single-field-to-multiple-fields/m-p/353692#M104683</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval Datacenter="FHD (1) | TDC (3) | SDC (2)"
| streamstats count AS _serial

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| makemv Delim=" | " Datacenter
| mvexpand Datacenter
| rex field=Datacenter "^(?&amp;lt;Key&amp;gt;\S+)\s+\((?&amp;lt;Value&amp;gt;.*)\)$"
| eval Datacenter_{Key} = Value
| fields - Datacenter Key Value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;At this point you should do your filtering logic on the new fields and if you need to merge back, you can add this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats values(*) AS * BY _serial
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Aug 2017 22:57:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-Multiple-Values-in-single-field-to-multiple-fields/m-p/353692#M104683</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-08-07T22:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Multiple Values in single field to multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-Multiple-Values-in-single-field-to-multiple-fields/m-p/353693#M104684</link>
      <description>&lt;P&gt;This actually worked out very well for me.  Thank you very much.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 02:47:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-Multiple-Values-in-single-field-to-multiple-fields/m-p/353693#M104684</guid>
      <dc:creator>matt4321</dc:creator>
      <dc:date>2017-08-08T02:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Multiple Values in single field to multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-Multiple-Values-in-single-field-to-multiple-fields/m-p/353694#M104685</link>
      <description>&lt;P&gt;This also worked out very well.. Would you know if this is possible to put into transforms.conf and props.conf?  if so any suggestions on how that would look?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 02:48:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-Multiple-Values-in-single-field-to-multiple-fields/m-p/353694#M104685</guid>
      <dc:creator>matt4321</dc:creator>
      <dc:date>2017-08-08T02:48:29Z</dc:date>
    </item>
  </channel>
</rss>

