<?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: Combine two rows from a search into one? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Combine-two-rows-from-a-search-into-one/m-p/218442#M64198</link>
    <description>&lt;P&gt;You don't need two rex commands in your search.  One is enough.&lt;/P&gt;</description>
    <pubDate>Thu, 23 Jun 2016 17:25:28 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2016-06-23T17:25:28Z</dc:date>
    <item>
      <title>Combine two rows from a search into one?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combine-two-rows-from-a-search-into-one/m-p/218437#M64193</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;

&lt;P&gt;I'm doing a search for some project information, specifically for a count of projects based on their Importance, a created field in our Project Online instance, using this string:&lt;/P&gt;

&lt;P&gt;index = projectonline | dedup ProjectName | search Importance!=NULL | stats  count by Importance |  eval Importance_slice = Importance + ", " + count | fields Importance_slice, count&lt;/P&gt;

&lt;P&gt;It's working pretty nicely but when we created the Importance field and look up table originally we used values High, Medium and Low then switched to 1 - High, 2 - Medium and 3 - Low.  This, I believe, has thrown my search a little bit and it returns this:&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://community.splunk.com/storage/temp/141236-capture.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;Now naturally what I'd like to do is combing the High and 1 - High rows, the Medium and 2 - Medium, and the Low and 3 - Low rows.  This will be for a piechart dasboard panel, so maybe sections of a piechart can be combined in the XML as a way to attack it from a different angle.  Anyways, can this be done in the search or XML?  I've been struggling with addtotals and the evals for this.  Any and all advice would be most welcome!&lt;/P&gt;

&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:00:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combine-two-rows-from-a-search-into-one/m-p/218437#M64193</guid>
      <dc:creator>dzenn</dc:creator>
      <dc:date>2020-09-29T10:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: Combine two rows from a search into one?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combine-two-rows-from-a-search-into-one/m-p/218438#M64194</link>
      <description>&lt;P&gt;Perhaps this will help.  Use sed to normalize the Importance values.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = projectonline | dedup ProjectName | search Importance!=NULL | rex field=Importance mode=sed "s/\d - (\w+)/\1/g" | stats count by Importance | eval Importance_slice = Importance + ", " + count | fields Importance_slice, count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Jun 2016 17:00:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combine-two-rows-from-a-search-into-one/m-p/218438#M64194</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-06-23T17:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: Combine two rows from a search into one?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combine-two-rows-from-a-search-into-one/m-p/218439#M64195</link>
      <description>&lt;P&gt;Add this before your stats command. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=Importance mode=sed "s/(\d\s-\s)(\w+)/$2/g" | stats ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Jun 2016 17:00:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combine-two-rows-from-a-search-into-one/m-p/218439#M64195</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-06-23T17:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: Combine two rows from a search into one?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combine-two-rows-from-a-search-into-one/m-p/218440#M64196</link>
      <description>&lt;P&gt;thank you for the suggestion!&lt;/P&gt;

&lt;P&gt;so after using search string:&lt;/P&gt;

&lt;P&gt;index = projectonline | dedup ProjectName | search Importance!=NULL | rex field=Importance mode=sed "s/\d - (\w+)/\1/g" | rex field=Importance mode=sed "s/(\d\s-\s)(\w+)/$2/g"| stats count by Importance | eval Importance_slice = Importance + ", " + count | fields Importance_slice, count&lt;/P&gt;

&lt;P&gt;The results seem to be combined but the totals are off:&lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://imgur.com/Y1UgrmQ" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;I've found that whether or not "rex field=Importance mode=sed "s/(\d\s-\s)(\w+)/$2/g" " is in the search or not the results are the same.&lt;/P&gt;

&lt;P&gt;I've never used sed or rex so unfortunately I'm rather ignorant of how they work &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:00:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combine-two-rows-from-a-search-into-one/m-p/218440#M64196</guid>
      <dc:creator>dzenn</dc:creator>
      <dc:date>2020-09-29T10:00:04Z</dc:date>
    </item>
    <item>
      <title>Re: Combine two rows from a search into one?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combine-two-rows-from-a-search-into-one/m-p/218441#M64197</link>
      <description>&lt;P&gt;&lt;A href="http://imgur.com/Y1UgrmQ"&gt;http://imgur.com/Y1UgrmQ&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;this is the image of the new results, for some reason you can't upload an image in the comments.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 17:11:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combine-two-rows-from-a-search-into-one/m-p/218441#M64197</guid>
      <dc:creator>dzenn</dc:creator>
      <dc:date>2016-06-23T17:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: Combine two rows from a search into one?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combine-two-rows-from-a-search-into-one/m-p/218442#M64198</link>
      <description>&lt;P&gt;You don't need two rex commands in your search.  One is enough.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 17:25:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combine-two-rows-from-a-search-into-one/m-p/218442#M64198</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-06-23T17:25:28Z</dc:date>
    </item>
  </channel>
</rss>

