<?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 create pivot like table in Reporting</title>
    <link>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465556#M7493</link>
    <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw= "ExtractStart,ExtractEnd,CM,CallCount
 12/12/2019 4:00,12/12/2019 4:15,CM2,55
 12/12/2019 4:00,12/12/2019 4:15,CE1,0
 12/12/2019 4:00,12/12/2019 4:15,CE3,28
 12/12/2019 4:00,12/12/2019 4:15,CM4,32
 12/12/2019 4:15,12/12/2019 4:30,CM2,192
 12/12/2019 4:15,12/12/2019 4:30,CE1,0
 12/12/2019 4:15,12/12/2019 4:30,CE3,95
 12/12/2019 4:15,12/12/2019 4:30,CM1,157
 12/12/2019 4:30,12/12/2019 4:45,CM2,197
 12/12/2019 4:30,12/12/2019 4:45,CE1,0
 12/12/2019 4:30,12/12/2019 4:45,CE3,92
 12/12/2019 4:30,12/12/2019 4:45,CM4,106
 12/12/2019 4:45,12/12/2019 5:00,CM2,208
 12/12/2019 4:45,12/12/2019 5:00,CE1,0
 12/12/2019 4:45,12/12/2019 5:00,CE3,112" 
| multikv forceheader=1 
| table ExtractStart,ExtractEnd,CM,CallCount 
`comment("the logic is below")`
| eval time=mvzip(ExtractStart,ExtractEnd) 
| chart limit=0 sum(CallCount) over time by CM 
| rex field=time "(?&amp;lt;ExtractStart&amp;gt;[^,]+),(?&amp;lt;ExtractEnd&amp;gt;.+)" 
| table ExtractStart ExtractEnd CM* CE* 
| fillnull
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;There are many possible answers.&lt;/P&gt;</description>
    <pubDate>Fri, 13 Dec 2019 12:09:04 GMT</pubDate>
    <dc:creator>to4kawa</dc:creator>
    <dc:date>2019-12-13T12:09:04Z</dc:date>
    <item>
      <title>how to create pivot like table</title>
      <link>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465552#M7489</link>
      <description>&lt;P&gt;I have an SPL query that produces a table output like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ExtractStart    ExtractEnd          CM  CallCount
12/12/2019 4:00 12/12/2019 4:15 CM2 55
12/12/2019 4:00 12/12/2019 4:15 CE1 0
12/12/2019 4:00 12/12/2019 4:15 CE3 28
12/12/2019 4:00 12/12/2019 4:15 CM4 32
12/12/2019 4:15 12/12/2019 4:30 CM2 192
12/12/2019 4:15 12/12/2019 4:30 CE1 0
12/12/2019 4:15 12/12/2019 4:30 CE3 95
12/12/2019 4:15 12/12/2019 4:30 CM1 157
12/12/2019 4:30 12/12/2019 4:45 CM2 197
12/12/2019 4:30 12/12/2019 4:45 CE1 0
12/12/2019 4:30 12/12/2019 4:45 CE3 92
12/12/2019 4:30 12/12/2019 4:45 CM4 106
12/12/2019 4:45 12/12/2019 5:00 CM2 208
12/12/2019 4:45 12/12/2019 5:00 CE1 0
12/12/2019 4:45 12/12/2019 5:00 CE3 112
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The query that produced the table above is this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=extract sourcetype=jobsummaries
| rex field=jobName "(?:\w+\s)?(?&amp;lt;CM&amp;gt;\w+)"
| rex field=rangeStart "(?&amp;lt;TS1&amp;gt;\d+-\d+-\d+\s\d+:\d+:\d+)\..+"
| rex field=rangeEnd "(?&amp;lt;TS2&amp;gt;\d+-\d+-\d+\s\d+:\d+:\d+)\..+"
| eval ExtractStart = strptime(TS1, "%Y-%m-%d %H:%M")
| eval ExtractStart = strftime(ExtractStart, "%Y-%m-%d %H:%M")
| eval ExtractEnd = strptime(TS2, "%Y-%m-%d %H:%M")
| eval ExtractEnd = strftime(ExtractEnd, "%Y-%m-%d %H:%M")
| eval today = relative_time(now(),"-0d@d")
| eval today = strftime(today, "%Y-%m-%d %H:%M")
| where ExtractStart &amp;gt;= today
| rename processedNewCalls as CallCount
| table execId ExtractStart ExtractEnd CM CallCount
| dedup execId
| fields - execId
| sort ExtractStart
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do I modify my query so that my table looks like this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ExtractStart    ExtractEnd         CM1  CM2 CM3 CE1  CE3
12/12/2019 4:00 12/12/2019 4:15 0     55    32    0 28
12/12/2019 4:15 12/12/2019 4:30 157 192   0    0    95
12/12/2019 4:30 12/12/2019 4:45 0     197   106  0  92
12/12/2019 4:45 12/12/2019 5:00 0     208   0     0 112
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Dec 2019 00:59:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465552#M7489</guid>
      <dc:creator>mmdacutanan</dc:creator>
      <dc:date>2019-12-13T00:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: how to create pivot like table</title>
      <link>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465553#M7490</link>
      <description>&lt;P&gt;like this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=extract sourcetype=jobsummaries
 | rex field=jobName "(?:\w+\s)?(?&amp;lt;CM&amp;gt;\w+)"
 | rex field=rangeStart "(?&amp;lt;TS1&amp;gt;\d+-\d+-\d+\s\d+:\d+:\d+)\..+"
 | rex field=rangeEnd "(?&amp;lt;TS2&amp;gt;\d+-\d+-\d+\s\d+:\d+:\d+)\..+"
 | eval ExtractStart = strptime(TS1, "%Y-%m-%d %H:%M")
 | eval ExtractStart = strftime(ExtractStart, "%Y-%m-%d %H:%M")
 | eval ExtractEnd = strptime(TS2, "%Y-%m-%d %H:%M")
 | eval ExtractEnd = strftime(ExtractEnd, "%Y-%m-%d %H:%M")
 | eval today = relative_time(now(),"-0d@d")
 | eval today = strftime(today, "%Y-%m-%d %H:%M")
 | where ExtractStart &amp;gt;= today
 | rename processedNewCalls as CallCount
 | table execId ExtractStart ExtractEnd CM CallCount
 | dedup execId
 | fields - execId

| stats values(CallCount) as calls by ExtractStart ExtractEnd CM 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;hope it helps&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2019 04:45:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465553#M7490</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2019-12-13T04:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to create pivot like table</title>
      <link>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465554#M7491</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw= "ExtractStart,ExtractEnd,CM,CallCount
12/12/2019 4:00,12/12/2019 4:15,CM2,55
12/12/2019 4:00,12/12/2019 4:15,CE1,0
12/12/2019 4:00,12/12/2019 4:15,CE3,28
12/12/2019 4:00,12/12/2019 4:15,CM4,32
12/12/2019 4:15,12/12/2019 4:30,CM2,192
12/12/2019 4:15,12/12/2019 4:30,CE1,0
12/12/2019 4:15,12/12/2019 4:30,CE3,95
12/12/2019 4:15,12/12/2019 4:30,CM1,157
12/12/2019 4:30,12/12/2019 4:45,CM2,197
12/12/2019 4:30,12/12/2019 4:45,CE1,0
12/12/2019 4:30,12/12/2019 4:45,CE3,92
12/12/2019 4:30,12/12/2019 4:45,CM4,106
12/12/2019 4:45,12/12/2019 5:00,CM2,208
12/12/2019 4:45,12/12/2019 5:00,CE1,0
12/12/2019 4:45,12/12/2019 5:00,CE3,112"
| multikv forceheader=1
| table ExtractStart,ExtractEnd,CM,CallCount

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution."

| eval raw = "ExtractStart=" . ExtractStart . " ExtractEnd=" . ExtractEnd
| fields - Extract*
| xyseries raw CM CallCount
| fillnull value=0
| rename raw AS _raw
| kv
| fields - _raw
| table ExtractStart ExtractEnd *
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Dec 2019 11:16:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465554#M7491</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-12-13T11:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to create pivot like table</title>
      <link>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465555#M7492</link>
      <description>&lt;P&gt;Never, EVER use &lt;CODE&gt;sort&lt;/CODE&gt; without a number (e.g. &lt;CODE&gt;sort 0 ...&lt;/CODE&gt; ).&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2019 11:17:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465555#M7492</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-12-13T11:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: how to create pivot like table</title>
      <link>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465556#M7493</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw= "ExtractStart,ExtractEnd,CM,CallCount
 12/12/2019 4:00,12/12/2019 4:15,CM2,55
 12/12/2019 4:00,12/12/2019 4:15,CE1,0
 12/12/2019 4:00,12/12/2019 4:15,CE3,28
 12/12/2019 4:00,12/12/2019 4:15,CM4,32
 12/12/2019 4:15,12/12/2019 4:30,CM2,192
 12/12/2019 4:15,12/12/2019 4:30,CE1,0
 12/12/2019 4:15,12/12/2019 4:30,CE3,95
 12/12/2019 4:15,12/12/2019 4:30,CM1,157
 12/12/2019 4:30,12/12/2019 4:45,CM2,197
 12/12/2019 4:30,12/12/2019 4:45,CE1,0
 12/12/2019 4:30,12/12/2019 4:45,CE3,92
 12/12/2019 4:30,12/12/2019 4:45,CM4,106
 12/12/2019 4:45,12/12/2019 5:00,CM2,208
 12/12/2019 4:45,12/12/2019 5:00,CE1,0
 12/12/2019 4:45,12/12/2019 5:00,CE3,112" 
| multikv forceheader=1 
| table ExtractStart,ExtractEnd,CM,CallCount 
`comment("the logic is below")`
| eval time=mvzip(ExtractStart,ExtractEnd) 
| chart limit=0 sum(CallCount) over time by CM 
| rex field=time "(?&amp;lt;ExtractStart&amp;gt;[^,]+),(?&amp;lt;ExtractEnd&amp;gt;.+)" 
| table ExtractStart ExtractEnd CM* CE* 
| fillnull
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;There are many possible answers.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2019 12:09:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465556#M7493</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-12-13T12:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to create pivot like table</title>
      <link>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465557#M7494</link>
      <description>&lt;P&gt;Hi @woodcock ! Thank you for taking time to look over my question. Really appreciate it! I like posting question here in Splunk Answers as I always learn neat tips and tricks that I would not have thought of!&lt;/P&gt;

&lt;P&gt;I tried your query and the output after the kv command only produced ExtractStart that only is blank while ExtractEnd only had the date - the time portion was dropped.&lt;/P&gt;

&lt;P&gt;After looking around in the internet, I tweaked the solution you gave me to use 'extract' command instead of KV. I also added a | as the delimiter in the concatenation so that I can split the 2 dates more easily:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval raw = "ExtractStart=" . ExtractStart . " | "."ExtractEnd=" . ExtractEnd
| fields - Extract*
| xyseries raw CM CallCount
| fillnull value=0
| rename raw AS _raw
| extract pairdelim="|" kvdelim="="
| fields - _raw
| table ExtractStart ExtractEnd *
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Still curious to see how to make the kv thing work if you don't mind sharing. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2019 22:41:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465557#M7494</guid>
      <dc:creator>mmdacutanan</dc:creator>
      <dc:date>2019-12-13T22:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: how to create pivot like table</title>
      <link>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465558#M7495</link>
      <description>&lt;P&gt;The docs are pretty clear (and it worked in my test example).  It is the same as &lt;CODE&gt;KV_MODE = auto&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2019 22:43:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465558#M7495</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-12-13T22:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: how to create pivot like table</title>
      <link>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465559#M7496</link>
      <description>&lt;P&gt;So the solution worked with a minor tweak?  If so, be sure to click &lt;CODE&gt;Accept&lt;/CODE&gt; to close the question.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2019 22:44:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465559#M7496</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-12-13T22:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to create pivot like table</title>
      <link>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465560#M7497</link>
      <description>&lt;P&gt;hi @to4kawa !! Thanks for taking time to look at my question! Your solution also works. Like you said, there are several possible answers. woodcock also had a suggestion that is somewhat similar to your but he used xyseries and kv.&lt;/P&gt;

&lt;P&gt;Learned a few things in this post which I am really thankful for! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2019 23:20:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465560#M7497</guid>
      <dc:creator>mmdacutanan</dc:creator>
      <dc:date>2019-12-13T23:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: how to create pivot like table</title>
      <link>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465561#M7498</link>
      <description>&lt;P&gt;Thanks, @mmdacutanan&lt;BR /&gt;
It ’s easy to understand this query.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;kv&lt;/CODE&gt; and &lt;CODE&gt;xyseries&lt;/CODE&gt; are good commands, let's use them. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2019 23:30:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465561#M7498</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-12-13T23:30:54Z</dc:date>
    </item>
    <item>
      <title>Re: how to create pivot like table</title>
      <link>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465562#M7499</link>
      <description>&lt;P&gt;Be sure to &lt;CODE&gt;UpVote&lt;/CODE&gt; around!&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2019 23:44:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465562#M7499</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-12-13T23:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to create pivot like table</title>
      <link>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465563#M7500</link>
      <description>&lt;P&gt;hi @woodcock ! I am embarrassed to ask but what is UpVote and how do I do it? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Dec 2019 00:02:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465563#M7500</guid>
      <dc:creator>mmdacutanan</dc:creator>
      <dc:date>2019-12-14T00:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to create pivot like table</title>
      <link>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465564#M7501</link>
      <description>&lt;P&gt;I just &lt;CODE&gt;UpVoted&lt;/CODE&gt; your comment.  Just click on the up-arrows. It is free.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Dec 2019 00:08:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/how-to-create-pivot-like-table/m-p/465564#M7501</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-12-14T00:08:15Z</dc:date>
    </item>
  </channel>
</rss>

