<?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 get diff count and show field and result of diff in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-diff-count-and-show-field-and-result-of-diff/m-p/497736#M138619</link>
    <description>&lt;P&gt;Hello Splunkers,&lt;/P&gt;

&lt;P&gt;I have a trouble with the result, example i have some data log&lt;/P&gt;

&lt;P&gt;Goat | alive&lt;BR /&gt;
Goat | dead&lt;BR /&gt;
Goat | alive&lt;/P&gt;

&lt;P&gt;Rabit | alive&lt;BR /&gt;
Rabit | dead&lt;/P&gt;

&lt;P&gt;my trouble is , how to get data count alive or dead , example a Goat (alive =2 , dead = 1) diff = alive - dead (1) , and Rabit(alive=1 , dead=1) diff = alive - dead (0), i want to create table of result &lt;BR /&gt;
Animal | alive | dead | diff&lt;BR /&gt;
Goat | 2 | 1 | 1&lt;BR /&gt;
Rabit | 1 | 1 | 0&lt;/P&gt;

&lt;P&gt;please help me for the query, thank you splunkers&lt;/P&gt;</description>
    <pubDate>Thu, 19 Mar 2020 11:12:03 GMT</pubDate>
    <dc:creator>mockingj</dc:creator>
    <dc:date>2020-03-19T11:12:03Z</dc:date>
    <item>
      <title>How to get diff count and show field and result of diff</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-diff-count-and-show-field-and-result-of-diff/m-p/497736#M138619</link>
      <description>&lt;P&gt;Hello Splunkers,&lt;/P&gt;

&lt;P&gt;I have a trouble with the result, example i have some data log&lt;/P&gt;

&lt;P&gt;Goat | alive&lt;BR /&gt;
Goat | dead&lt;BR /&gt;
Goat | alive&lt;/P&gt;

&lt;P&gt;Rabit | alive&lt;BR /&gt;
Rabit | dead&lt;/P&gt;

&lt;P&gt;my trouble is , how to get data count alive or dead , example a Goat (alive =2 , dead = 1) diff = alive - dead (1) , and Rabit(alive=1 , dead=1) diff = alive - dead (0), i want to create table of result &lt;BR /&gt;
Animal | alive | dead | diff&lt;BR /&gt;
Goat | 2 | 1 | 1&lt;BR /&gt;
Rabit | 1 | 1 | 0&lt;/P&gt;

&lt;P&gt;please help me for the query, thank you splunkers&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2020 11:12:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-diff-count-and-show-field-and-result-of-diff/m-p/497736#M138619</guid>
      <dc:creator>mockingj</dc:creator>
      <dc:date>2020-03-19T11:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to get diff count and show field and result of diff</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-diff-count-and-show-field-and-result-of-diff/m-p/497737#M138620</link>
      <description>&lt;P&gt;hi @mockingj,&lt;/P&gt;

&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="_raw
Goat | alive
Goat | dead
Goat | alive
Rabit | alive
Rabit | dead" 
| multikv forceheader=1 
| rex "(?&amp;lt;Animal&amp;gt;\w+)\s\|\s(?&amp;lt;status&amp;gt;\w+)" 
| stats count(eval(status="alive")) as alive, count(eval(status="dead")) as dead by Animal 
| eval diff=alive-dead
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Mar 2020 12:50:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-diff-count-and-show-field-and-result-of-diff/m-p/497737#M138620</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-03-19T12:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to get diff count and show field and result of diff</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-diff-count-and-show-field-and-result-of-diff/m-p/497738#M138621</link>
      <description>&lt;P&gt;See if this helps.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats count(eval(state="alive")) as AliveCount, count(eval(state="dead")) as DeadCount by Animal
| eval diff = AliveCount - DeadCount
| table Animal, AliveCount, DeadCount, diff
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Mar 2020 12:50:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-diff-count-and-show-field-and-result-of-diff/m-p/497738#M138621</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-03-19T12:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to get diff count and show field and result of diff</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-diff-count-and-show-field-and-result-of-diff/m-p/497739#M138622</link>
      <description>&lt;P&gt;wonderful answer :)) , the best word &lt;STRONG&gt;by Animal&lt;/STRONG&gt; , thank you very much&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2020 14:08:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-diff-count-and-show-field-and-result-of-diff/m-p/497739#M138622</guid>
      <dc:creator>mockingj</dc:creator>
      <dc:date>2020-03-19T14:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to get diff count and show field and result of diff</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-diff-count-and-show-field-and-result-of-diff/m-p/497740#M138623</link>
      <description>&lt;P&gt;thanks you for your answer&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2020 14:10:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-diff-count-and-show-field-and-result-of-diff/m-p/497740#M138623</guid>
      <dc:creator>mockingj</dc:creator>
      <dc:date>2020-03-19T14:10:48Z</dc:date>
    </item>
  </channel>
</rss>

