<?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 do I rename field values and add up the count(*) if the value is the same? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-rename-field-values-and-add-up-the-count-if-the-value/m-p/445244#M126310</link>
    <description>&lt;P&gt;How do I rename field values, and if the values are same, add up the corresponding count value?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="abc" earliest=-d latest=now StatusCode="4*" OR StatusCode="5*" OR StatusCode="206 *" OR StatusCode="3*"  | stats count(StatusCode) AS NoOfFailures by StatusCode
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The result i get is &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;StatusCode               | count(StatusCode)
206 Partial Content      | 5
400 Bad Request          |  8
404 Not Found            | 3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then i add rename for the fields&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="abc" earliest=-d latest=now StatusCode="4*" OR StatusCode="5*" OR StatusCode="206 *" OR StatusCode="3*"  | stats count(StatusCode) AS NoOfFailures by StatusCode | replace "404 Not Found" with "Medium", "206 Partial Content" with "Low", "400 Bad Request" with "Medium" | table StatusCode,NoOfFailures
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The result i get is&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;StatusCode              | count(StatusCode)
LOW                     | 5
Medium                  |  8
Medium                  | 3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But the result i want is &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;StatusCode              | count(StatusCode)
LOW                     | 5
Medium                  |  11 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;11 = 8+3 (i.e., I want all with value as medium to be in one row with the total number of count(*)&lt;/P&gt;

&lt;P&gt;Can anybody help me how to do this?&lt;/P&gt;</description>
    <pubDate>Tue, 05 Feb 2019 09:28:47 GMT</pubDate>
    <dc:creator>rohanmiskin</dc:creator>
    <dc:date>2019-02-05T09:28:47Z</dc:date>
    <item>
      <title>How do I rename field values and add up the count(*) if the value is the same?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-rename-field-values-and-add-up-the-count-if-the-value/m-p/445244#M126310</link>
      <description>&lt;P&gt;How do I rename field values, and if the values are same, add up the corresponding count value?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="abc" earliest=-d latest=now StatusCode="4*" OR StatusCode="5*" OR StatusCode="206 *" OR StatusCode="3*"  | stats count(StatusCode) AS NoOfFailures by StatusCode
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The result i get is &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;StatusCode               | count(StatusCode)
206 Partial Content      | 5
400 Bad Request          |  8
404 Not Found            | 3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then i add rename for the fields&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="abc" earliest=-d latest=now StatusCode="4*" OR StatusCode="5*" OR StatusCode="206 *" OR StatusCode="3*"  | stats count(StatusCode) AS NoOfFailures by StatusCode | replace "404 Not Found" with "Medium", "206 Partial Content" with "Low", "400 Bad Request" with "Medium" | table StatusCode,NoOfFailures
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The result i get is&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;StatusCode              | count(StatusCode)
LOW                     | 5
Medium                  |  8
Medium                  | 3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But the result i want is &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;StatusCode              | count(StatusCode)
LOW                     | 5
Medium                  |  11 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;11 = 8+3 (i.e., I want all with value as medium to be in one row with the total number of count(*)&lt;/P&gt;

&lt;P&gt;Can anybody help me how to do this?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 09:28:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-rename-field-values-and-add-up-the-count-if-the-value/m-p/445244#M126310</guid>
      <dc:creator>rohanmiskin</dc:creator>
      <dc:date>2019-02-05T09:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I rename field values and add up the count(*) if the value is the same?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-rename-field-values-and-add-up-the-count-if-the-value/m-p/445245#M126311</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;Try this &lt;CODE&gt;index="abc" earliest=-d latest=now StatusCode="4*" OR StatusCode="5*" OR StatusCode="206 " OR StatusCode="3" | eval statusSeverity = case(StatusCode=="404 Not Found", "Medium, StatusCode=="206 Partial Content", true(), "Unknown") | stats count by statusSeverity&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 09:50:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-rename-field-values-and-add-up-the-count-if-the-value/m-p/445245#M126311</guid>
      <dc:creator>chrisyounger</dc:creator>
      <dc:date>2019-02-05T09:50:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do I rename field values and add up the count(*) if the value is the same?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-rename-field-values-and-add-up-the-count-if-the-value/m-p/445246#M126312</link>
      <description>&lt;P&gt;hi @rohanmiskin &lt;/P&gt;

&lt;P&gt;try like this  &lt;CODE&gt;index="abc" earliest=-d latest=now StatusCode="4*" OR StatusCode="5*" OR StatusCode="206 " OR StatusCode="3" | stats count(StatusCode) as NoOfFailures by StatusCode | replace "404 Not Found" with "Medium", "206 Partial Content" with "Low", "400 Bad Request" with "Medium" | table StatusCode,NoOfFailures |stats sum(NoOfFailures) as NoofFailure by StatusCode&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 10:14:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-rename-field-values-and-add-up-the-count-if-the-value/m-p/445246#M126312</guid>
      <dc:creator>harishalipaka</dc:creator>
      <dc:date>2019-02-05T10:14:17Z</dc:date>
    </item>
    <item>
      <title>Re: How do I rename field values and add up the count(*) if the value is the same?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-rename-field-values-and-add-up-the-count-if-the-value/m-p/445247#M126313</link>
      <description>&lt;P&gt;Yup, this works perfectly. Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2019 11:29:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-rename-field-values-and-add-up-the-count-if-the-value/m-p/445247#M126313</guid>
      <dc:creator>rohanmiskin</dc:creator>
      <dc:date>2019-02-06T11:29:08Z</dc:date>
    </item>
  </channel>
</rss>

