<?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 transform a table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-transform-a-table/m-p/474466#M192480</link>
    <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw=" time        session           event
 t1          session1            actionA
 t2          session1            actionB
 t3          session1            actionC
 t4          session1            actionA
 t5          session2            actionB
 t6          session2            actionC" 
| multikv forceheader=1 
| streamstats count as time_args 
| eval time_args="+".time_args."h@h-1d" 
| eval time=relative_time(_time,time_args) 
| eval _time=time 
| table _time session event 
| rename COMMENT as "this is sample you provide. from here, the logic"
| streamstats window=2 range(_time) as duration list(event) as event_list count(event) as counts by session 
| where counts=2 
| eval event_list=mvjoin(event_list,",") 
| stats sum(counts) as count sum(duration) as timetaken by event_list 
| eval from=mvindex(split(event_list,","),0), to=mvindex(split(event_list,","),1), timetaken=tostring(round(timetaken),"duration") 
| table from to count timetaken
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How about this?&lt;/P&gt;</description>
    <pubDate>Thu, 09 Apr 2020 21:28:10 GMT</pubDate>
    <dc:creator>to4kawa</dc:creator>
    <dc:date>2020-04-09T21:28:10Z</dc:date>
    <item>
      <title>How to transform a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-transform-a-table/m-p/474465#M192479</link>
      <description>&lt;P&gt;If I have the data in following format:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;time        session           event
t1          session1            actionA
t2          session1            actionB
t3          session1            actionC
t4          session1            actionA
t5          session2            actionB
t6          session2            actionC
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;want to write a splunk query to transform it to this format:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;from         to           count    timetaken
actionA      actionB      1        (t2-t1)
actionB      actionC.     2        (t3-t2) + (t5+t6)
actionC      actionA      1        (t4-t3)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;can someone recommend an expression for this?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Apr 2020 18:38:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-transform-a-table/m-p/474465#M192479</guid>
      <dc:creator>dtakacssplunk</dc:creator>
      <dc:date>2020-04-09T18:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to transform a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-transform-a-table/m-p/474466#M192480</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw=" time        session           event
 t1          session1            actionA
 t2          session1            actionB
 t3          session1            actionC
 t4          session1            actionA
 t5          session2            actionB
 t6          session2            actionC" 
| multikv forceheader=1 
| streamstats count as time_args 
| eval time_args="+".time_args."h@h-1d" 
| eval time=relative_time(_time,time_args) 
| eval _time=time 
| table _time session event 
| rename COMMENT as "this is sample you provide. from here, the logic"
| streamstats window=2 range(_time) as duration list(event) as event_list count(event) as counts by session 
| where counts=2 
| eval event_list=mvjoin(event_list,",") 
| stats sum(counts) as count sum(duration) as timetaken by event_list 
| eval from=mvindex(split(event_list,","),0), to=mvindex(split(event_list,","),1), timetaken=tostring(round(timetaken),"duration") 
| table from to count timetaken
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How about this?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Apr 2020 21:28:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-transform-a-table/m-p/474466#M192480</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-09T21:28:10Z</dc:date>
    </item>
  </channel>
</rss>

