<?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 combine multiple rows into different columns on single row in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-multiple-rows-into-different-columns-on-single/m-p/522607#M147366</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/158208"&gt;@hpendela&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are a couple of slightly different ways to do this. The first&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw="Status,Count
200,800
404,34
400,20
500,12"
| multikv forceheader=1
| table Status, Count
| eval Count({Status})=Count
| fields - Count
| stats values(Count*) as Count*&lt;/LI-CODE&gt;&lt;P&gt;Take the last 3 lines, which gives exactly your example.&lt;/P&gt;&lt;P&gt;This is slightly different in that it does not rename the fields as you want, but achieves the same goal.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw="Status,Count
200,800
404,34
400,20
500,12"
| multikv forceheader=1
| table Status, Count
| transpose 0 column_name="Count" header_field=Status&lt;/LI-CODE&gt;&lt;P&gt;Just the last line will do this&lt;/P&gt;&lt;P&gt;or you can add the next two lines to give the exact same&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| fields - Count
| foreach * [ rename "&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;" as "Count(&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;)" ]&lt;/LI-CODE&gt;&lt;P&gt;Hope this helps&lt;/P&gt;</description>
    <pubDate>Thu, 01 Oct 2020 23:35:58 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2020-10-01T23:35:58Z</dc:date>
    <item>
      <title>How to combine multiple rows into different columns on single row</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-multiple-rows-into-different-columns-on-single/m-p/522601#M147363</link>
      <description>&lt;P&gt;I have a query that returns the following result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%"&gt;&lt;STRONG&gt;Status&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="50%"&gt;&lt;STRONG&gt;Count&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;800&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;404&lt;/TD&gt;&lt;TD&gt;34&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I would like to transform it to something like this&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%"&gt;&lt;STRONG&gt;Count(200)&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%"&gt;&lt;STRONG&gt;Count(404)&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%"&gt;&lt;STRONG&gt;Count(400)&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%"&gt;&lt;STRONG&gt;&amp;nbsp;Count(500)&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;800&lt;/TD&gt;&lt;TD&gt;34&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this possible? Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2020 22:27:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-multiple-rows-into-different-columns-on-single/m-p/522601#M147363</guid>
      <dc:creator>hpendela</dc:creator>
      <dc:date>2020-10-01T22:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine multiple rows into different columns on single row</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-multiple-rows-into-different-columns-on-single/m-p/522607#M147366</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/158208"&gt;@hpendela&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are a couple of slightly different ways to do this. The first&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw="Status,Count
200,800
404,34
400,20
500,12"
| multikv forceheader=1
| table Status, Count
| eval Count({Status})=Count
| fields - Count
| stats values(Count*) as Count*&lt;/LI-CODE&gt;&lt;P&gt;Take the last 3 lines, which gives exactly your example.&lt;/P&gt;&lt;P&gt;This is slightly different in that it does not rename the fields as you want, but achieves the same goal.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw="Status,Count
200,800
404,34
400,20
500,12"
| multikv forceheader=1
| table Status, Count
| transpose 0 column_name="Count" header_field=Status&lt;/LI-CODE&gt;&lt;P&gt;Just the last line will do this&lt;/P&gt;&lt;P&gt;or you can add the next two lines to give the exact same&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| fields - Count
| foreach * [ rename "&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;" as "Count(&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;)" ]&lt;/LI-CODE&gt;&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2020 23:35:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-multiple-rows-into-different-columns-on-single/m-p/522607#M147366</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2020-10-01T23:35:58Z</dc:date>
    </item>
  </channel>
</rss>

