<?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: Conditional count using tstats in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Conditional-count-using-tstats/m-p/318114#M95191</link>
    <description>&lt;P&gt;thank you &lt;/P&gt;</description>
    <pubDate>Wed, 17 Jan 2018 18:06:01 GMT</pubDate>
    <dc:creator>eranday</dc:creator>
    <dc:date>2018-01-17T18:06:01Z</dc:date>
    <item>
      <title>Conditional count using tstats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-count-using-tstats/m-p/318110#M95187</link>
      <description>&lt;P&gt;Is it possible to do a conditional count using tstats?&lt;BR /&gt;
I want to count specific event_type: (count if(event_type = 'xxxxx'))    as num_of_x&lt;/P&gt;

&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:44:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-count-using-tstats/m-p/318110#M95187</guid>
      <dc:creator>eranday</dc:creator>
      <dc:date>2020-09-29T17:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional count using tstats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-count-using-tstats/m-p/318111#M95188</link>
      <description>&lt;P&gt;Short answer is no. The complex aggregation command like yours are not supported by tstats. See this for more information&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/Tstats#Complex_aggregate_functions"&gt;http://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/Tstats#Complex_aggregate_functions&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;If the field that you're planning to use in your complex aggregation is an indexed field (then only it's available to tstats command), you can try workaround like this (sample)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats count WHERE index=foo sourcetype=bar (event_type="xxxxx" OR event_type="yyyyy") by field1 field2 event_type
| stats sum(eval(if(event_type="xxxxxx",count,0))) as num_of_x sum(eval(if(event_type="yyyyy",count,0))) as num_of_y by field1 field2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Jan 2018 17:51:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-count-using-tstats/m-p/318111#M95188</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-01-17T17:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional count using tstats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-count-using-tstats/m-p/318112#M95189</link>
      <description>&lt;P&gt;Hey @eranday&lt;BR /&gt;
The tstats command does not support complex aggregate functions such as ...&lt;CODE&gt;count(eval('event_type'=="failure"))&lt;/CODE&gt;&lt;BR /&gt;
This is mentioned in this official doc &lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Tstats#Complex_aggregate_functions"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Tstats#Complex_aggregate_functions&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;If you want to use then separate out the aggregate functions from the eval functions, as shown in the following search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats count FROM ..&amp;lt;your_basequery&amp;gt; | stats count(eval(event_type="xxxxx")) as num_of_x
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;let me know if this helps !&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2018 17:59:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-count-using-tstats/m-p/318112#M95189</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-17T17:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional count using tstats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-count-using-tstats/m-p/318113#M95190</link>
      <description>&lt;P&gt;thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2018 18:05:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-count-using-tstats/m-p/318113#M95190</guid>
      <dc:creator>eranday</dc:creator>
      <dc:date>2018-01-17T18:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional count using tstats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-count-using-tstats/m-p/318114#M95191</link>
      <description>&lt;P&gt;thank you &lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2018 18:06:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-count-using-tstats/m-p/318114#M95191</guid>
      <dc:creator>eranday</dc:creator>
      <dc:date>2018-01-17T18:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional count using tstats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-count-using-tstats/m-p/318115#M95192</link>
      <description>&lt;P&gt;I posted a somewhat gnarly way to do what you want to do in another answer (&lt;A href="https://answers.splunk.com/answers/229076/is-it-possible-to-do-a-conditional-count-using-tst.html"&gt;link&lt;/A&gt;).&lt;/P&gt;

&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 15:35:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-count-using-tstats/m-p/318115#M95192</guid>
      <dc:creator>Kenshiro70</dc:creator>
      <dc:date>2018-03-21T15:35:11Z</dc:date>
    </item>
  </channel>
</rss>

