<?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 split count of field1 where (field2=value1) and count of field1 where (field2=value2) without appending? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-count-of-field1-where-field2-value1-and-count-of/m-p/451132#M127761</link>
    <description>&lt;P&gt;Close this worked for me&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats sum(eval(if(SE="DISCONNECTED",count_CA,0))) as disconnected_count, sum(eval(if(SE="CONNECTED",count_CA,0))) as connected_count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Feel free to change your comment into an answer, I can mark it as answered.&lt;/P&gt;</description>
    <pubDate>Wed, 20 Mar 2019 20:36:15 GMT</pubDate>
    <dc:creator>JoshuaJohn</dc:creator>
    <dc:date>2019-03-20T20:36:15Z</dc:date>
    <item>
      <title>How to split count of field1 where (field2=value1) and count of field1 where (field2=value2) without appending?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-count-of-field1-where-field2-value1-and-count-of/m-p/451130#M127759</link>
      <description>&lt;P&gt;I want to find how many times an event happens based on the value of another field. Basically a count of IP addresses when they are  "Connected" or "Disconnected".&lt;/P&gt;

&lt;P&gt;CA is the IP address&lt;BR /&gt;
SE is what tells me if they are connected/disconnected&lt;/P&gt;

&lt;P&gt;I feel like this should be simple, but I have tried a few things to no avail:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats latest(SE) as SE by CA
| stats distinct_count(CA) as count_CA by SE
| stats dc(eval(if(SE=DISCONNECTED, count_CA, NULL))) AS disconnected_CA, dc(eval(if(SE=CONNECTED, count_CA, NULL))) AS connected_CA
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Provides 0 in both fields (Not true)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats latest(SE) as SE by CA
| eval disconnectedCheck = if(SE==DISCONNECTED, disconnected_SE, disconnectedCheck)
| stats dc(CA) as disconnected_CA by disconnected_SE
| stats values(disconnected_CA)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;No Results&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats latest(SE) as SE by CA
| stats distinct_count(CA) as count_CA by SE
| eventstats sum(count_CA) as total_CA
| search SE = "DISCONNECTED" 
| eventstats values(count_CA) as disconnected_CA
| search SE = "CONNECTED" 
| eventstats values(count_CA) as connected_CA, values(total_CA) as total_CA
| eval Percentage=round((disconnected_CA/total_CA)*100,2)
| table disconnected_CA, total_CA, connected_CA, Percentage
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;No results&lt;/P&gt;

&lt;P&gt;Any Ideas, would prefer not to append if possible?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2019 16:38:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-count-of-field1-where-field2-value1-and-count-of/m-p/451130#M127759</guid>
      <dc:creator>JoshuaJohn</dc:creator>
      <dc:date>2019-03-20T16:38:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to split count of field1 where (field2=value1) and count of field1 where (field2=value2) without appending?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-count-of-field1-where-field2-value1-and-count-of/m-p/451131#M127760</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I didn't understand your question properly but have you tried something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yoursearch&amp;gt;
| stats sum(eval(if(SE="DISCONNECTED",1,0))) as disconnected_count, sum(eval(if(SE="CONNECTED",1,0))) as connected_count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Mar 2019 17:12:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-count-of-field1-where-field2-value1-and-count-of/m-p/451131#M127760</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2019-03-20T17:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to split count of field1 where (field2=value1) and count of field1 where (field2=value2) without appending?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-count-of-field1-where-field2-value1-and-count-of/m-p/451132#M127761</link>
      <description>&lt;P&gt;Close this worked for me&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats sum(eval(if(SE="DISCONNECTED",count_CA,0))) as disconnected_count, sum(eval(if(SE="CONNECTED",count_CA,0))) as connected_count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Feel free to change your comment into an answer, I can mark it as answered.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2019 20:36:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-count-of-field1-where-field2-value1-and-count-of/m-p/451132#M127761</guid>
      <dc:creator>JoshuaJohn</dc:creator>
      <dc:date>2019-03-20T20:36:15Z</dc:date>
    </item>
  </channel>
</rss>

