<?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: How to split a column into multiple columns? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-multiple-columns/m-p/399027#M115688</link>
    <description>&lt;P&gt;Hi dopjiepreji, &lt;/P&gt;

&lt;P&gt;Unfortunately, doing exactly what you want is impossible in Splunk. There is no way that you can have duplicate column names in standard SPL (although you might be able to do it in XML of a dashboard). &lt;/P&gt;

&lt;P&gt;The following SPL should be very close to what you wanted, but it's a bit "hacky" so I wouldn't recommend this approach. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search name=missed*
| sort name
| appendcols [
 | search name=score*
 | sort name
 | rename name as name1, count as count1
]
| table name, count, name1, count1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This search is slightly different from what you requested, but it is much more the "Splunk way". &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=name "(?&amp;lt;class&amp;gt;missed|score)(?&amp;lt;type&amp;gt;.*)"
| stats sum(count) as count by type, class
| xyseries class, type, count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hopefully you can find a way to make this work better with your real data. I had to use "|rex" to extract information from "name" in the sample you provided to get it working. &lt;/P&gt;</description>
    <pubDate>Wed, 29 May 2019 12:36:42 GMT</pubDate>
    <dc:creator>tomaszdziwok</dc:creator>
    <dc:date>2019-05-29T12:36:42Z</dc:date>
    <item>
      <title>How to split a column into multiple columns?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-multiple-columns/m-p/399026#M115687</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a table that looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;name       | count
score1and2 | 1
score1     | 2
score2     | 2
missed1and2| 3
missed1    | 2
missed2    | 2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to arrange the table like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;name       | count     |  name       | count
score1and2 | 1         | missed1and2 | 3
score1     | 2         | missed1     | 2
score2     | 2         | missed2     | 2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I've tried using chart and tried different arrangements of by and over clauses but to no avail. &lt;BR /&gt;
Any help would be appreciated. Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 11:25:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-multiple-columns/m-p/399026#M115687</guid>
      <dc:creator>dojiepreji</dc:creator>
      <dc:date>2019-05-29T11:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a column into multiple columns?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-multiple-columns/m-p/399027#M115688</link>
      <description>&lt;P&gt;Hi dopjiepreji, &lt;/P&gt;

&lt;P&gt;Unfortunately, doing exactly what you want is impossible in Splunk. There is no way that you can have duplicate column names in standard SPL (although you might be able to do it in XML of a dashboard). &lt;/P&gt;

&lt;P&gt;The following SPL should be very close to what you wanted, but it's a bit "hacky" so I wouldn't recommend this approach. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search name=missed*
| sort name
| appendcols [
 | search name=score*
 | sort name
 | rename name as name1, count as count1
]
| table name, count, name1, count1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This search is slightly different from what you requested, but it is much more the "Splunk way". &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=name "(?&amp;lt;class&amp;gt;missed|score)(?&amp;lt;type&amp;gt;.*)"
| stats sum(count) as count by type, class
| xyseries class, type, count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hopefully you can find a way to make this work better with your real data. I had to use "|rex" to extract information from "name" in the sample you provided to get it working. &lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 12:36:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-multiple-columns/m-p/399027#M115688</guid>
      <dc:creator>tomaszdziwok</dc:creator>
      <dc:date>2019-05-29T12:36:42Z</dc:date>
    </item>
  </channel>
</rss>

