<?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 How can I stack the rows vertically while preserving the original columns in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-stack-the-rows-vertically-while-preserving-the/m-p/687754#M234562</link>
    <description>&lt;P&gt;I have a search that returns the following table (after transpose):&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;column&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;row 1&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;row 2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;search_name&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;UC-315&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;UC-231&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;ID&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;7zAt/7&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;5Dfxdf&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;Time&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;13:27:17&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;09:17:09&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;And I need it to look like this:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;column&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;new_row&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;search_name&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;UC-315&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;ID&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;7zAt/7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;Time&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;13:27:17&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;search_name&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;UC-231&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;ID&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;5Dfxdf&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="24px"&gt;Time&lt;/TD&gt;&lt;TD height="24px"&gt;09:17:09&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;This should work independently of the amount of rows.&lt;BR /&gt;I've tried using mvexpand, and streamstats but without any luck.&lt;/P&gt;</description>
    <pubDate>Thu, 16 May 2024 15:06:45 GMT</pubDate>
    <dc:creator>rar0</dc:creator>
    <dc:date>2024-05-16T15:06:45Z</dc:date>
    <item>
      <title>How can I stack the rows vertically while preserving the original columns</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-stack-the-rows-vertically-while-preserving-the/m-p/687754#M234562</link>
      <description>&lt;P&gt;I have a search that returns the following table (after transpose):&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;column&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;row 1&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;row 2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;search_name&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;UC-315&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;UC-231&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;ID&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;7zAt/7&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;5Dfxdf&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;Time&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;13:27:17&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;09:17:09&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;And I need it to look like this:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;column&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;new_row&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;search_name&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;UC-315&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;ID&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;7zAt/7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;Time&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;13:27:17&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;search_name&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;UC-231&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;ID&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;5Dfxdf&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="24px"&gt;Time&lt;/TD&gt;&lt;TD height="24px"&gt;09:17:09&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;This should work independently of the amount of rows.&lt;BR /&gt;I've tried using mvexpand, and streamstats but without any luck.&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2024 15:06:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-stack-the-rows-vertically-while-preserving-the/m-p/687754#M234562</guid>
      <dc:creator>rar0</dc:creator>
      <dc:date>2024-05-16T15:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: How can I stack the rows vertically while preserving the original columns</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-stack-the-rows-vertically-while-preserving-the/m-p/687771#M234574</link>
      <description>&lt;P&gt;Assuming you can still be dependent on column names, you should go back to pre-transpose and add the following&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval row=mvrange(0,3)
| mvexpand row
| eval column=mvindex(split("search_name,ID,Time",","),row)
| eval new_row=case(row=0,search_name,row=1,ID,row=2,Time)
| table column new_row&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 16 May 2024 16:59:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-stack-the-rows-vertically-while-preserving-the/m-p/687771#M234574</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-05-16T16:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: How can I stack the rows vertically while preserving the original columns</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-stack-the-rows-vertically-while-preserving-the/m-p/687801#M234584</link>
      <description>&lt;P&gt;As always, the answer depends a lot on data characteristics and the real problem you are trying to solve. &amp;nbsp;Maybe you can explain why the second look, which is highly unconventional, is more desirable? &amp;nbsp;Is it safe to say that search_name, ID, and Time are a triplet that should be treated as a unit? &amp;nbsp;In that case, wouldn't this form be more human friendly?&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;Time&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;search_name&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ID&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;&lt;SPAN&gt;13:27:17&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;&lt;SPAN&gt;UC-315&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;7zAt/7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;13:27:17&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;UC-231&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;&amp;nbsp;&lt;SPAN&gt;5Dfxdf&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;(This, of course is the default time series aka Splunky presentation.)&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 00:04:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-stack-the-rows-vertically-while-preserving-the/m-p/687801#M234584</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-05-17T00:04:04Z</dc:date>
    </item>
    <item>
      <title>Re: How can I stack the rows vertically while preserving the original columns</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-stack-the-rows-vertically-while-preserving-the/m-p/688137#M234647</link>
      <description>&lt;P&gt;Thanks for your fast responses.&lt;BR /&gt;&lt;BR /&gt;Some more context: For incidence response, we want to generate a text block with all notables below each other where a security analyst can write his conclusion below every notable, like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;* Short-lived group membership
ID:                 F3y4IS
Time:               05/14/2024 11:12:28
Destination:        xyz
Source User:        abc
User / Group:       def
Destination Group:  ghi
--&amp;gt; 

* Usage of Default Account "administrator"
ID:                 L32op/, WTBxMy
Date:               05/17/2024 20:39:04
Destination:        xyz
Source User:        abc
User / Group:       def
Destination Group:  ghi
--&amp;gt; 

* Malware detected ...&lt;/LI-CODE&gt;&lt;P&gt;For this, I already wrote the following query to get the current notables to analyse:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;`notable`
| search urgency IN ("high", "critical") status_label IN ("Unassigned", "New", "In Progress") NOT `suppression`
| lookup notable_xref_lookup event_id OUTPUT xref_id AS ID
| table search_name ID _time `text_block_fields_default`&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;If I transpose this, I get the first table I posted. In the macro `text_block_fields_default` are interesting fields to include in the report like "action, app, dest, src, etc". So the solution shouldn't be dependent on column names.&lt;BR /&gt;&lt;BR /&gt;I already have this query which generates the text block for 1 specific notable:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;`notable`
| search event_id="BAAAD325-8391-4075-81A2-AB145A1FA2FB@@notable@@80497c055c45b92d73bd74e700c1b6f9"
| lookup notable_xref_lookup event_id OUTPUT xref_id AS ID
| table search_name ID _time `text_block_fields_default`
| `ctime(_time)`
| rename _time as time
| transpose include_empty=False column_name=text_block
| eval row 1=mvjoin('row 1',",")
| eval text_block=if(text_block="search_name","* ",text_block.":                      "),text_block=replace(text_block,"(.{21}).*","\1") 
| eval text_block=text_block . 'row 1'
| append [| makeresults | eval text_block="--&amp;gt; " ]
| table text_block&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Thanks in advance for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2024 09:51:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-stack-the-rows-vertically-while-preserving-the/m-p/688137#M234647</guid>
      <dc:creator>rar0</dc:creator>
      <dc:date>2024-05-21T09:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: How can I stack the rows vertically while preserving the original columns</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-stack-the-rows-vertically-while-preserving-the/m-p/688250#M234666</link>
      <description>&lt;P&gt;This is an interesting use case. &amp;nbsp;Here is an idea based on&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;'s prototype.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;`notable`
| search urgency IN ("high", "critical") status_label IN ("Unassigned", "New", "In Progress") NOT `suppression`
| lookup notable_xref_lookup event_id OUTPUT xref_id AS ID
| foreach search_name ID _time `text_block_fields_default`
    [eval row = mvappend(row, json_object("name", "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;", "value", &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;))]
| table row
| mvexpand row
| eval column = json_extract(row, "name"), new_row = json_extract(row, "value")
| fields - row&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(JSON functions requires 8.1 or higher. &amp;nbsp;The same can be achieved using the traditional string concatenation method.) Using this mock data&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;search_name&lt;/TD&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;_time&lt;/TD&gt;&lt;TD&gt;bar&lt;/TD&gt;&lt;TD&gt;foo&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;UC-315&lt;/TD&gt;&lt;TD&gt;7zAt/7&lt;/TD&gt;&lt;TD&gt;13:27:17&lt;/TD&gt;&lt;TD&gt;bar1&lt;/TD&gt;&lt;TD&gt;foo1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;UC-231&lt;/TD&gt;&lt;TD&gt;5Dfxdf&lt;/TD&gt;&lt;TD&gt;13:27:17&lt;/TD&gt;&lt;TD&gt;bar2&lt;/TD&gt;&lt;TD&gt;foo2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;output will be: (bar, foo, of course, represents&amp;nbsp;`text_block_fields_default`)&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;column&lt;/TD&gt;&lt;TD&gt;new_row&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;search_name&lt;/TD&gt;&lt;TD&gt;UC-315&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;7zAt/7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;_time&lt;/TD&gt;&lt;TD&gt;13:27:17&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;bar&lt;/TD&gt;&lt;TD&gt;bar1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;foo&lt;/TD&gt;&lt;TD&gt;foo1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;search_name&lt;/TD&gt;&lt;TD&gt;UC-231&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;5Dfxdf&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;_time&lt;/TD&gt;&lt;TD&gt;13:27:17&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;bar&lt;/TD&gt;&lt;TD&gt;bar2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;foo&lt;/TD&gt;&lt;TD&gt;foo2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Here is the full emulation&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults format=csv data="search_name, 	ID, _time,	foo, bar
UC-315,	7zAt/7, 13:27:17,	foo1, bar1
UC-231,	 5Dfxdf, 13:27:17,	foo2, bar2"
| table search_name ID _time *
``` the above emulates
`notable`
| search urgency IN ("high", "critical") status_label IN ("Unassigned", "New", "In Progress") NOT `suppression`
| lookup notable_xref_lookup event_id OUTPUT xref_id AS ID
```
| foreach search_name ID _time * ``` * represents `text_block_fields_default` ```
    [eval row = mvappend(row, json_object("name", "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;", "value", &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;))]
| table row
| mvexpand row
| eval column = json_extract(row, "name"), new_row = json_extract(row, "value")
| fields - row&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 06:50:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-stack-the-rows-vertically-while-preserving-the/m-p/688250#M234666</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-05-22T06:50:25Z</dc:date>
    </item>
  </channel>
</rss>

