<?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: split columns based on delimeter in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/split-columns-based-on-delimeter/m-p/416873#M119958</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/193316"&gt;@surekhasplunk&lt;/a&gt;,&lt;/P&gt;

&lt;P&gt;Please try below search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval categories="Finance/Banking, General News, Search Engines" 
| makemv categories delim=", " 
| eval order="1,2,3,4,5,6,7,8,9,10" 
| makemv order delim="," 
| eval cat=mvzip(order,categories)
| mvexpand cat
| rex field=cat "^(?&amp;lt;order&amp;gt;\d+),(?&amp;lt;cat&amp;gt;.*)"
| eval category_{order} = cat
| fields - order,cat
| stats values(*) as * by _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In your search fields other than categories, put all in place of _time in this query. This search can accept categories value upto 10 (meaning you can have category_1 up to category_10), if you want more add more in the query. Replace first two lines with your existing query.&lt;/P&gt;

&lt;P&gt;Hope this helps!!!&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 00:50:26 GMT</pubDate>
    <dc:creator>VatsalJagani</dc:creator>
    <dc:date>2020-09-30T00:50:26Z</dc:date>
    <item>
      <title>split columns based on delimeter</title>
      <link>https://community.splunk.com/t5/Splunk-Search/split-columns-based-on-delimeter/m-p/416871#M119956</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a field called categories. And the values look like below. Please help me with regex or a way to split them and add values to new columns. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;General News
Instant Messaging, Web Phone
Business, Software/Hardware
Search Engines
Finance/Banking, General News, Search Engines
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;categories| category1 | category2 | category3
General News | General News
Instant Messaging, Web Phone | Instant Messaging | Web Phone
Finance/Banking, General News, Search Engines | Finance/Banking | General News | Search Engines
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Basically delimeted with comma. &lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2019 10:51:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/split-columns-based-on-delimeter/m-p/416871#M119956</guid>
      <dc:creator>surekhasplunk</dc:creator>
      <dc:date>2019-06-10T10:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: split columns based on delimeter</title>
      <link>https://community.splunk.com/t5/Splunk-Search/split-columns-based-on-delimeter/m-p/416872#M119957</link>
      <description>&lt;P&gt;@surekhasplunk &lt;/P&gt;

&lt;P&gt;Can you please try this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR_SEARCH | eval category1=mvindex(split(categories,","),0),category2=mvindex(split(categories,","),1), category3=mvindex(split(categories,","),2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Sample Search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval categories="General News|Instant Messaging, Web Phone|Business, Software/Hardware|Search Engines|Finance/Banking, General News, Search Engines" 
| eval categories=split(categories,"|") 
| mvexpand categories 
| eval category1=mvindex(split(categories,","),0),category2=mvindex(split(categories,","),1), category3=mvindex(split(categories,","),2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2019 11:08:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/split-columns-based-on-delimeter/m-p/416872#M119957</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-06-10T11:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: split columns based on delimeter</title>
      <link>https://community.splunk.com/t5/Splunk-Search/split-columns-based-on-delimeter/m-p/416873#M119958</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/193316"&gt;@surekhasplunk&lt;/a&gt;,&lt;/P&gt;

&lt;P&gt;Please try below search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval categories="Finance/Banking, General News, Search Engines" 
| makemv categories delim=", " 
| eval order="1,2,3,4,5,6,7,8,9,10" 
| makemv order delim="," 
| eval cat=mvzip(order,categories)
| mvexpand cat
| rex field=cat "^(?&amp;lt;order&amp;gt;\d+),(?&amp;lt;cat&amp;gt;.*)"
| eval category_{order} = cat
| fields - order,cat
| stats values(*) as * by _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In your search fields other than categories, put all in place of _time in this query. This search can accept categories value upto 10 (meaning you can have category_1 up to category_10), if you want more add more in the query. Replace first two lines with your existing query.&lt;/P&gt;

&lt;P&gt;Hope this helps!!!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:50:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/split-columns-based-on-delimeter/m-p/416873#M119958</guid>
      <dc:creator>VatsalJagani</dc:creator>
      <dc:date>2020-09-30T00:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: split columns based on delimeter</title>
      <link>https://community.splunk.com/t5/Splunk-Search/split-columns-based-on-delimeter/m-p/416874#M119959</link>
      <description>&lt;P&gt;Please checkout answer by @kamlesh_vaghela where he used  &lt;CODE&gt;mvindex&lt;/CODE&gt; command. Check whichever is faster use that.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2019 12:04:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/split-columns-based-on-delimeter/m-p/416874#M119959</guid>
      <dc:creator>VatsalJagani</dc:creator>
      <dc:date>2019-06-10T12:04:55Z</dc:date>
    </item>
  </channel>
</rss>

