<?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: How to sum the count of two fields when they have the same value? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-count-of-two-fields-when-they-have-the-same-value/m-p/202863#M58894</link>
    <description>&lt;P&gt;Perfect.. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;</description>
    <pubDate>Thu, 14 Apr 2016 17:52:29 GMT</pubDate>
    <dc:creator>vasanthmss</dc:creator>
    <dc:date>2016-04-14T17:52:29Z</dc:date>
    <item>
      <title>How to sum the count of two fields when they have the same value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-count-of-two-fields-when-they-have-the-same-value/m-p/202858#M58889</link>
      <description>&lt;P&gt;I have data where each event has two fields to show the source and destination city of a package.I can get the count of each city separately, but am struggling to show a combined count.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=foo | stats count by destCity&lt;/CODE&gt;    -- returns a count of events for each destination city.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;destCity             count
Baltimore            5
Philli               3
Toronto             20
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;CODE&gt;index=foo | stats count by sourceCity&lt;/CODE&gt;   -- returns the count of events for each source city.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourceCity       count
Atlanta                7
Baltimore            5
Toronto            15
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I need to be able to calculate:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;country         count
Atlanta              7
Baltimore       10
Philli                  3
Toronto         35
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Apr 2016 16:01:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-count-of-two-fields-when-they-have-the-same-value/m-p/202858#M58889</guid>
      <dc:creator>lyndac</dc:creator>
      <dc:date>2016-04-14T16:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum the count of two fields when they have the same value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-count-of-two-fields-when-they-have-the-same-value/m-p/202859#M58890</link>
      <description>&lt;P&gt;I think this is as simple as &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval city=mvappend(sourceCity,destCity) | stats count by city
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Whether a given event has both fields, or has just one or the other, it will still work.   &lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 16:06:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-count-of-two-fields-when-they-have-the-same-value/m-p/202859#M58890</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2016-04-14T16:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum the count of two fields when they have the same value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-count-of-two-fields-when-they-have-the-same-value/m-p/202860#M58891</link>
      <description>&lt;P&gt;Try this, &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo | eval country=coalesce(destCity, sourceCity) | stats count by country
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
V&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 16:14:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-count-of-two-fields-when-they-have-the-same-value/m-p/202860#M58891</guid>
      <dc:creator>vasanthmss</dc:creator>
      <dc:date>2016-04-14T16:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum the count of two fields when they have the same value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-count-of-two-fields-when-they-have-the-same-value/m-p/202861#M58892</link>
      <description>&lt;P&gt;Note this will not work properly whenever an event has both destCity and sourceCity fields - in such cases it will disregard that event's sourceCity field.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 16:56:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-count-of-two-fields-when-they-have-the-same-value/m-p/202861#M58892</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2016-04-14T16:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum the count of two fields when they have the same value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-count-of-two-fields-when-they-have-the-same-value/m-p/202862#M58893</link>
      <description>&lt;P&gt;I found that when I tried it.  Most of my events have both fields.  The mvappend worked beautifully!&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 16:59:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-count-of-two-fields-when-they-have-the-same-value/m-p/202862#M58893</guid>
      <dc:creator>lyndac</dc:creator>
      <dc:date>2016-04-14T16:59:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum the count of two fields when they have the same value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-count-of-two-fields-when-they-have-the-same-value/m-p/202863#M58894</link>
      <description>&lt;P&gt;Perfect.. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 17:52:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-count-of-two-fields-when-they-have-the-same-value/m-p/202863#M58894</guid>
      <dc:creator>vasanthmss</dc:creator>
      <dc:date>2016-04-14T17:52:29Z</dc:date>
    </item>
  </channel>
</rss>

