<?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/217379#M187992</link>
    <description>&lt;P&gt;Not sure if that was the requirement (normalization). Would agree on strftime change if event though the field name is _time, use is storing string formatted time in it.&lt;/P&gt;</description>
    <pubDate>Thu, 23 Jun 2016 15:35:04 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2016-06-23T15:35:04Z</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/217375#M187988</link>
      <description>&lt;P&gt;I have this table:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time,id,src,dst
9:00,x,A,B
9:01,x,B,C
9:02,y,C,B
9:03,z,B,C
9:04,y,B,A
9:05,z,C,D
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I wanna create this table:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time,id,A-B,B-C,C-D
9:00,x,9:00,9:01,
9:02,y,9:04,9:02,
9:03,z,,9:03,9:05
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How can I transform the table?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 02:55:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-transform-a-table/m-p/217375#M187988</guid>
      <dc:creator>i111040d</dc:creator>
      <dc:date>2016-06-23T02:55:55Z</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/217376#M187989</link>
      <description>&lt;P&gt;Add this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=_time mode=sed "s/://"
| eval transition = src . "-" . dst . "::" . dst . "-" . src | fields - src dst
| makemv delim="::" transition | mvexpand transition
| stats values(transition) AS transition BY _time id | eval transition = mvindex(transition, 0)
| chart first(_time) AS _time BY id transition
| eval time="9999" | foreach * [ eval time = min(time, $&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;$) | rex field="&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;" mode=sed "s/(\d{1,2})(\d{2})/\1:\2/" ]
| rex field=time mode=sed "s/(\d{1,2})(\d{2})/\1:\2/"
| table time id *
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Jun 2016 03:30:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-transform-a-table/m-p/217376#M187989</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-06-23T03:30:45Z</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/217377#M187990</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your current search giving _time id src dst | eval temp=src."-".dst."#".strftime(_time,"%H:%M")
| stats first(_time) as _time values(temp) as temp by id 
| mvexpand temp | rex field=temp "(?&amp;lt;direction&amp;gt;.+)#(?&amp;lt;time&amp;gt;.+)"
| eval temp=_time."#".id | chart values(time) over temp by direction | rex field=temp "(?&amp;lt;_time&amp;gt;.+)#(?&amp;lt;id&amp;gt;.+)" | fields - temp
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Update#1&lt;/STRONG&gt;&lt;BR /&gt;
Thanks @woodcock for clarifying the requirement. This should take care of normalization as well.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; your current search giving _time id src dst | eval Nodes=mvsort(split(src."-".dst,"-")) | eval temp=mvindex(Nodes,0)."-".mvindex(Nodes,1)."#"._time | stats first(_time) as _time values(temp) as temp by id 
 | mvexpand temp | rex field=temp "(?&amp;lt;direction&amp;gt;.+)#(?&amp;lt;time&amp;gt;.+)"  | eval temp=_time."#".id | chart values(time) over temp by direction | rex field=temp "(?&amp;lt;_time&amp;gt;.+)#(?&amp;lt;id&amp;gt;.+)" | fields - temp| table _time id *
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Jun 2016 14:54:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-transform-a-table/m-p/217377#M187990</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-06-23T14:54:50Z</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/217378#M187991</link>
      <description>&lt;P&gt;Yours does not normalize &lt;CODE&gt;B-A&lt;/CODE&gt; to be &lt;CODE&gt;A-B&lt;/CODE&gt; so the results are wrong:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time   id  A-B B-A B-C C-B C-D
9:00    x   9:00        9:01         
9:02    y       9:04        9:02     
9:03    z           9:03        9:05
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also, you must change &lt;CODE&gt;strftime(_time, "%H,%M")&lt;/CODE&gt; to just &lt;CODE&gt;_time&lt;/CODE&gt;.  Use this to spoof test events:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|noop|stats count AS trash|eval trash="9:00,x,A,B::9:01,x,B,C::9:02,y,C,B::9:03,z,B,C::9:04,y,B,A::9:05,z,C,D"
|makemv delim="::" trash|mvexpand trash
| rex field=trash "(?&amp;lt;_time&amp;gt;.*?),(?&amp;lt;id&amp;gt;.*?),(?&amp;lt;src&amp;gt;.*?),(?&amp;lt;dst&amp;gt;.*)" | table _time id src dst
| rename DesiredResults AS "
_time,id,A-B,B-C,C-D
9:00,x,9:00,9:01,
9:02,y,9:04,9:02,
9:03,z,,9:03,9:05"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Jun 2016 15:17:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-transform-a-table/m-p/217378#M187991</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-06-23T15:17:12Z</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/217379#M187992</link>
      <description>&lt;P&gt;Not sure if that was the requirement (normalization). Would agree on strftime change if event though the field name is _time, use is storing string formatted time in it.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 15:35:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-transform-a-table/m-p/217379#M187992</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-06-23T15:35:04Z</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/217380#M187993</link>
      <description>&lt;P&gt;Normalization is specified in the desired results given.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 15:38:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-transform-a-table/m-p/217380#M187993</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-06-23T15:38:37Z</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/217381#M187994</link>
      <description>&lt;P&gt;I did miss that. The answer updated to take care of both.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 15:54:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-transform-a-table/m-p/217381#M187994</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-06-23T15:54:31Z</dc:date>
    </item>
  </channel>
</rss>

