<?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 to merge cells in a table based on value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-cells-in-a-table-based-on-value/m-p/285239#M86278</link>
    <description>&lt;P&gt;I have a table like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;col1        | col2     | col3
samevalue   | value1   | value2
samevalue   | value3   | value4
samevalue   | value6   | value5
samevalue2  | value1   | value2
samevalue 2 | value3   | value4
samevalue 2 | value6   | value5
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I want to achieve is to merge the cells in col1, where the value is the same as the cell above, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;col1        | col2     |  col3
samevalue   | value1   | value2
            | value3   | value4
            | value6   | value5
samevalue2  | value1   | value2
            | value3   | value4
            | value6   | value5
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm producing the table with pivot, but in that column I need some sort of the grouping as I would have with stats, but without messing up the relation between the rows in other columns&lt;/P&gt;

&lt;P&gt;Edit: my padding was broken when I posted the question, sorry&lt;/P&gt;</description>
    <pubDate>Wed, 27 Jul 2016 15:50:56 GMT</pubDate>
    <dc:creator>szabados</dc:creator>
    <dc:date>2016-07-27T15:50:56Z</dc:date>
    <item>
      <title>How to merge cells in a table based on value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-cells-in-a-table-based-on-value/m-p/285239#M86278</link>
      <description>&lt;P&gt;I have a table like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;col1        | col2     | col3
samevalue   | value1   | value2
samevalue   | value3   | value4
samevalue   | value6   | value5
samevalue2  | value1   | value2
samevalue 2 | value3   | value4
samevalue 2 | value6   | value5
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I want to achieve is to merge the cells in col1, where the value is the same as the cell above, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;col1        | col2     |  col3
samevalue   | value1   | value2
            | value3   | value4
            | value6   | value5
samevalue2  | value1   | value2
            | value3   | value4
            | value6   | value5
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm producing the table with pivot, but in that column I need some sort of the grouping as I would have with stats, but without messing up the relation between the rows in other columns&lt;/P&gt;

&lt;P&gt;Edit: my padding was broken when I posted the question, sorry&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jul 2016 15:50:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-cells-in-a-table-based-on-value/m-p/285239#M86278</guid>
      <dc:creator>szabados</dc:creator>
      <dc:date>2016-07-27T15:50:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge cells in a table based on value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-cells-in-a-table-based-on-value/m-p/285240#M86279</link>
      <description>&lt;P&gt;If I understand correctly, you can do this with a combination of &lt;CODE&gt;streamstats&lt;/CODE&gt; and &lt;CODE&gt;eval&lt;/CODE&gt;.  In the below example, streamstats appends the previous col1 value to the current record.  The eval statement then sets col1 to blank if the value hasn't changed.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search
| sort col1 col2 
| streamstats current=f window=1 global=f last(col1) as last_col1 
| eval col1=if(col1==last_col1,'',col1)
| table col1 col2 col3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This link gave me some guidance on using the streamstats statement:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/87382/comparing-fields-with-previous-events.html"&gt;https://answers.splunk.com/answers/87382/comparing-fields-with-previous-events.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jul 2016 18:21:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-cells-in-a-table-based-on-value/m-p/285240#M86279</guid>
      <dc:creator>kbarker302</dc:creator>
      <dc:date>2016-07-27T18:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge cells in a table based on value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-cells-in-a-table-based-on-value/m-p/285241#M86280</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | stats values(col2) as col2 values(col3) as col3 by col1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Jul 2016 19:35:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-cells-in-a-table-based-on-value/m-p/285241#M86280</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-07-27T19:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge cells in a table based on value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-cells-in-a-table-based-on-value/m-p/285242#M86281</link>
      <description>&lt;P&gt;Thanks!&lt;/P&gt;

&lt;P&gt;Not exactly the same approach as I head in my head, but I like it a lot.&lt;BR /&gt;
I learned something new again.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2016 07:52:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-cells-in-a-table-based-on-value/m-p/285242#M86281</guid>
      <dc:creator>szabados</dc:creator>
      <dc:date>2016-07-28T07:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge cells in a table based on value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-cells-in-a-table-based-on-value/m-p/285243#M86282</link>
      <description>&lt;P&gt;Thank you - I used custom JavaScript to solve a similar issue previously, but your question made me reconsider whether there was a way to do it purely with SPL.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2016 14:39:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-cells-in-a-table-based-on-value/m-p/285243#M86282</guid>
      <dc:creator>kbarker302</dc:creator>
      <dc:date>2016-07-28T14:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge cells in a table based on value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-cells-in-a-table-based-on-value/m-p/285244#M86283</link>
      <description>&lt;P&gt;Just wanted to say thank you for this clever solution, it helped me immensely today!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2017 18:44:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-cells-in-a-table-based-on-value/m-p/285244#M86283</guid>
      <dc:creator>adam_reber</dc:creator>
      <dc:date>2017-08-30T18:44:29Z</dc:date>
    </item>
  </channel>
</rss>

