<?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 Stats (count(x) as countX, count(y) as countY) BY FIELD X in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Stats-count-x-as-countX-count-y-as-countY-BY-FIELD-X/m-p/316039#M4340</link>
    <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;As the title suggests, I am after a query which gives me both the values of count(x) and count(y) by fieldX to be used later on in queries. &lt;/P&gt;

&lt;P&gt;Is this possible?&lt;/P&gt;

&lt;P&gt;Virtual beer and kudos for the best answer.&lt;/P&gt;

&lt;P&gt;Kr,&lt;/P&gt;</description>
    <pubDate>Fri, 01 Sep 2017 21:28:47 GMT</pubDate>
    <dc:creator>JgTheGreat</dc:creator>
    <dc:date>2017-09-01T21:28:47Z</dc:date>
    <item>
      <title>Stats (count(x) as countX, count(y) as countY) BY FIELD X</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Stats-count-x-as-countX-count-y-as-countY-BY-FIELD-X/m-p/316039#M4340</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;As the title suggests, I am after a query which gives me both the values of count(x) and count(y) by fieldX to be used later on in queries. &lt;/P&gt;

&lt;P&gt;Is this possible?&lt;/P&gt;

&lt;P&gt;Virtual beer and kudos for the best answer.&lt;/P&gt;

&lt;P&gt;Kr,&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 21:28:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Stats-count-x-as-countX-count-y-as-countY-BY-FIELD-X/m-p/316039#M4340</guid>
      <dc:creator>JgTheGreat</dc:creator>
      <dc:date>2017-09-01T21:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: Stats (count(x) as countX, count(y) as countY) BY FIELD X</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Stats-count-x-as-countX-count-y-as-countY-BY-FIELD-X/m-p/316040#M4341</link>
      <description>&lt;P&gt;If I understand what you're looking for, you have two fields, which likely aren't in 100% of events, otherwise the counts would be the same. &lt;/P&gt;

&lt;P&gt;Try something like this to get counts when fields equal a certain value:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|stats count(eval(field="x")) as x_count count(eval(field="y")) as y_count by fieldX
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or this to just count how many events are in a field called y and a field called x&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|stats count(x) as x_count count(y) as y_count by fieldX
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Sep 2017 21:36:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Stats-count-x-as-countX-count-y-as-countY-BY-FIELD-X/m-p/316040#M4341</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-09-01T21:36:23Z</dc:date>
    </item>
  </channel>
</rss>

