<?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 invert lines and columns in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-invert-lines-and-columns/m-p/469852#M132210</link>
    <description>&lt;P&gt;Thanks a lot, it worked perfectly with the 1st answer.&lt;/P&gt;</description>
    <pubDate>Fri, 27 Dec 2019 13:02:24 GMT</pubDate>
    <dc:creator>gduc</dc:creator>
    <dc:date>2019-12-27T13:02:24Z</dc:date>
    <item>
      <title>How to invert lines and columns</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-invert-lines-and-columns/m-p/469848#M132206</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;Sorry for the language, I'm French. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;I'm executing this request with this lookup file:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=xxxxxxxxxx u_ci_group_entity="xxxxxxxxx" cmd=check_interface_traffic
| fields svc, ds, u_ci_name, traffic_in_int, traffic_out_int, if_alias
| dedup svc, ds
| lookup collecte_orange_liste_interfaces_to_transportes u_ci_name if_alias OUTPUT valide group
| eval heures_charge = if (valide = "oui" , 0 , 1 )
| search heures_charge = 0
| stats sum(traffic_in_int) as "somme_in", sum(traffic_out_int) as "somme_out", latest(_time) as "_time" by group 
| eval total_in_out_To=(somme_in+somme_out)/1024/1024/1024/1024, weeknumber=strftime(_time,"%V-%Y")
| table _time weeknumber group total_in_out_To
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/8115i90FB35500DE16AC5/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;My question is: &lt;BR /&gt;
How can I invert lines and columns in the table to get this:&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/8116i1AFCE54EA7C905CD/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;The goal is to use outputlookup function to save results in CSV file as 1 line per week.&lt;/P&gt;

&lt;P&gt;Thanks for helping.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Dec 2019 15:05:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-invert-lines-and-columns/m-p/469848#M132206</guid>
      <dc:creator>gduc</dc:creator>
      <dc:date>2019-12-26T15:05:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to invert lines and columns</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-invert-lines-and-columns/m-p/469849#M132207</link>
      <description>&lt;P&gt;The problem is with your &lt;CODE&gt;stats&lt;/CODE&gt; command and using &lt;CODE&gt;by group&lt;/CODE&gt;. Anytime you pass a field after the by clause, it will add multiple rows. If you remove the by clause, then it will show 1 row&lt;/P&gt;</description>
      <pubDate>Thu, 26 Dec 2019 17:46:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-invert-lines-and-columns/m-p/469849#M132207</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2019-12-26T17:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to invert lines and columns</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-invert-lines-and-columns/m-p/469850#M132208</link>
      <description>&lt;P&gt;Here is a solution that may work for you. Everything before &lt;CODE&gt;eventstats&lt;/CODE&gt; is kludge to get the data.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval data="2019-12-26 15:35:49,52-2019,ATM,0.178748;
2019-12-26 15:36:26,52-2019,BVPNIPNET,0.685878;
2019-12-26 15:32:45,52-2019,N2THD,0.046377;
2019-12-26 15:36:25,52-2019,PST,5.507981" 
| makemv data delim=";" | mvexpand data | rex field=data "(\s|\n?)(?&amp;lt;data&amp;gt;.*)" | makemv data delim=","
| eval _time=strptime(mvindex(data,0),"%Y-%m-%d %H:%M:%S"),
     weeknumber=mvindex(data,1),
     group=mvindex(data,2),
     total_in_out_To=mvindex(data,3)
| fields _time weeknumber group total_in_out_To
| eventstats first(_time) AS FirstTime | eval temp=FirstTime."~".weeknumber
| stats first(temp) AS temp first(weeknumber) AS weeknumber first(total_in_out_To) AS Val BY group
| xyseries temp group Val
| rex field=temp "^(?&amp;lt;FirstTime&amp;gt;[^\~]*)~(?&amp;lt;weeknumber&amp;gt;[^\e]*)"
| fields - temp | eval FirstTime=strftime(FirstTime,"%Y-%m-%d %H:%M:%S")
| table FirstTime weeknumber *
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is the output:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;FirstTime             weeknumber    ATM      BVPNIPNET   N2THD     PST
2019-12-26 15:35:49 52-2019    0.178748 0.685878    0.046377    5.507981
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Dec 2019 19:16:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-invert-lines-and-columns/m-p/469850#M132208</guid>
      <dc:creator>jpolvino</dc:creator>
      <dc:date>2019-12-26T19:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to invert lines and columns</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-invert-lines-and-columns/m-p/469851#M132209</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="xxxxxxxxxx" AND u_ci_group_entity="xxxxxxxxx" AND cmd="check_interface_traffic"
| fields svc, ds, u_ci_name, traffic_in_int, traffic_out_int, if_alias
| dedup svc, ds
| lookup collecte_orange_liste_interfaces_to_transportes u_ci_name if_alias OUTPUT valide group
| search valide = "oui"
| stats sum(traffic_in_int) AS"somme_in", sum(traffic_out_int) AS "somme_out", latest(_time) AS "_time" BY group
| eval total_in_out_To=(somme_in + somme_out)/1024/1024/1024/1024,
| fields - somme_in somme_out
| xyseries _time group total_in_out_To
| eval weeknumber=strftime(_time,"%V-%Y")
| table _time weeknumber *
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Dec 2019 19:49:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-invert-lines-and-columns/m-p/469851#M132209</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-12-26T19:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to invert lines and columns</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-invert-lines-and-columns/m-p/469852#M132210</link>
      <description>&lt;P&gt;Thanks a lot, it worked perfectly with the 1st answer.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Dec 2019 13:02:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-invert-lines-and-columns/m-p/469852#M132210</guid>
      <dc:creator>gduc</dc:creator>
      <dc:date>2019-12-27T13:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to invert lines and columns</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-invert-lines-and-columns/m-p/469853#M132211</link>
      <description>&lt;P&gt;@gduc, If your problem is resolved, please accept an answer to help future readers.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Dec 2019 14:57:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-invert-lines-and-columns/m-p/469853#M132211</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-12-27T14:57:41Z</dc:date>
    </item>
  </channel>
</rss>

