<?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 combine chart count for two fields in one search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-chart-count-for-two-fields-in-one-search/m-p/426654#M122244</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Can any one help me adding two fields in one search I am seeing both fields in splunk selected fields  but not seeing new field in Search result.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Query : Basic Search AND body.response.failedUpcName=* OR body.failedUpcName=* | chart count by body.response.failedUpcName , body.failedUpcName

Old Field Name : body.response.failedUpcName     
New Field Name : body.failedUpcName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How to get results for both Fields ?&lt;/P&gt;</description>
    <pubDate>Sun, 04 Aug 2019 04:44:08 GMT</pubDate>
    <dc:creator>monipinni</dc:creator>
    <dc:date>2019-08-04T04:44:08Z</dc:date>
    <item>
      <title>How to combine chart count for two fields in one search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-chart-count-for-two-fields-in-one-search/m-p/426654#M122244</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Can any one help me adding two fields in one search I am seeing both fields in splunk selected fields  but not seeing new field in Search result.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Query : Basic Search AND body.response.failedUpcName=* OR body.failedUpcName=* | chart count by body.response.failedUpcName , body.failedUpcName

Old Field Name : body.response.failedUpcName     
New Field Name : body.failedUpcName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How to get results for both Fields ?&lt;/P&gt;</description>
      <pubDate>Sun, 04 Aug 2019 04:44:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-chart-count-for-two-fields-in-one-search/m-p/426654#M122244</guid>
      <dc:creator>monipinni</dc:creator>
      <dc:date>2019-08-04T04:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine chart count for two fields in one search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-chart-count-for-two-fields-in-one-search/m-p/426655#M122245</link>
      <description>&lt;P&gt;Does it work if you replace chart with this stats example?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | stats count(field1) count(field2)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 04 Aug 2019 12:58:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-chart-count-for-two-fields-in-one-search/m-p/426655#M122245</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2019-08-04T12:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine chart count for two fields in one search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-chart-count-for-two-fields-in-one-search/m-p/426656#M122246</link>
      <description>&lt;P&gt;Try this,&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;
Basic Search AND body.response.failedUpcName=* OR body.failedUpcName=* &lt;BR /&gt;
| rename body.response.failedUpcName as response_failedUpcName, body.failedUpcName as failedUpcName  &lt;BR /&gt;
| chart count by response_failedUpcName , failedUpcName&lt;BR /&gt;
&lt;/CODE&gt;&lt;BR /&gt;
Not sure on the exact reason for this, however reporting commands don't seem to be able to handle nested fields very well.&lt;/P&gt;

&lt;P&gt;If your goal is to get the fields separately&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;
Basic Search AND body.response.failedUpcName=* OR body.failedUpcName=* &lt;BR /&gt;
| rename body.response.failedUpcName as response_failedUpcName, body.failedUpcName as failedUpcName  &lt;BR /&gt;
|fields response_failedUpcName, failedUpcName  &lt;BR /&gt;
| chart count(*) as *&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;If your goal is to get count based on one or the other based on what is available&lt;BR /&gt;
&lt;CODE&gt;&lt;BR /&gt;
Basic Search AND body.response.failedUpcName=* OR body.failedUpcName=* &lt;BR /&gt;
| rename body.response.failedUpcName as response_failedUpcName, body.failedUpcName as failedUpcName  &lt;BR /&gt;
| eval failedUpcName = coalesce(response_failedUpcName, failedUpcName) &lt;BR /&gt;
| chart count by failedUpcName &lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Aug 2019 14:39:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-chart-count-for-two-fields-in-one-search/m-p/426656#M122246</guid>
      <dc:creator>arjunpkishore5</dc:creator>
      <dc:date>2019-08-04T14:39:13Z</dc:date>
    </item>
  </channel>
</rss>

