<?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 edit the conditional count in my stats/eval search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-the-conditional-count-in-my-stats-eval-search/m-p/290064#M87701</link>
    <description>&lt;P&gt;You're comparing string so value of the month should be in double quotes. ( &lt;CODE&gt;count(eval(date_month=july)&lt;/CODE&gt; should be  &lt;CODE&gt;count(eval(date_month="july"))&lt;/CODE&gt;)&lt;/P&gt;</description>
    <pubDate>Tue, 15 Aug 2017 16:46:37 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2017-08-15T16:46:37Z</dc:date>
    <item>
      <title>How to edit the conditional count in my stats/eval search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-the-conditional-count-in-my-stats-eval-search/m-p/290063#M87700</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I am trying to add fields for month and include the count of tickets in each month. I bolded the part of the search below that is not loading data correctly. This is my current search but &lt;CODE&gt;count(eval(date_month=august))&lt;/CODE&gt; is showing zero but if I search &lt;CODE&gt;date_month=august | stats count as AUG&lt;/CODE&gt;- I get the actual number. What is my problem?&lt;/P&gt;

&lt;P&gt;index=indexname $oci$ | stats &lt;STRONG&gt;count(eval(date_month=july)) as JUL, count(eval(date_month=august)) as AUG, count(eval(date_month=september)) as SEP, count(eval(date_month=october)) as OCT, count(eval(date_month=november)) as NOV, count(eval(date_month=december)) as DEC, count(eval(date_month=january)) as JAN, count(eval(date_month=february)) as FEB, count(eval(date_month=march)) as MAR, count(eval(date_month=april)) as APR, count(eval(date_month=may)) as MAY, count(eval(date_month=june)) as JUN&lt;/STRONG&gt;, count as TOTAL by cmdb_ci | join type=outer overwrite=false cmdb_ci [search index=it_snow_call_kiosk_logs_weekly| stats count as TicketCount by cmdb_ci date_month | stats avg(TicketCount) as Baseline by cmdb_ci] | eval Baseline = round(Baseline,0) | table cmdb_ci Baseline JUL AUG SEP OCT NOV DEC JAN FEB MAR APR MAY JUN TOTAL | sort 0 -TOTAL&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:26:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-the-conditional-count-in-my-stats-eval-search/m-p/290063#M87700</guid>
      <dc:creator>katzr</dc:creator>
      <dc:date>2020-09-29T15:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit the conditional count in my stats/eval search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-the-conditional-count-in-my-stats-eval-search/m-p/290064#M87701</link>
      <description>&lt;P&gt;You're comparing string so value of the month should be in double quotes. ( &lt;CODE&gt;count(eval(date_month=july)&lt;/CODE&gt; should be  &lt;CODE&gt;count(eval(date_month="july"))&lt;/CODE&gt;)&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2017 16:46:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-the-conditional-count-in-my-stats-eval-search/m-p/290064#M87701</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-08-15T16:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit the conditional count in my stats/eval search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-the-conditional-count-in-my-stats-eval-search/m-p/290065#M87702</link>
      <description>&lt;P&gt;try this,&lt;/P&gt;

&lt;P&gt;index=indexname $oci$ | timechart span=1mon count as TOTAL by cmdb_ci | eval date_month=strftime(_time,"%b") | join type=outer overwrite=false cmdb_ci [search index=it_snow_call_kiosk_logs_weekly| stats count as TicketCount by cmdb_ci date_month | stats avg(TicketCount) as Baseline by cmdb_ci] | eval Baseline = round(Baseline,0) | table cmdb_ci Baseline date_month TOTAL | sort 0 -TOTAL&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:26:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-the-conditional-count-in-my-stats-eval-search/m-p/290065#M87702</guid>
      <dc:creator>sbbadri</dc:creator>
      <dc:date>2020-09-29T15:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit the conditional count in my stats/eval search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-the-conditional-count-in-my-stats-eval-search/m-p/290066#M87703</link>
      <description>&lt;P&gt;This is tricky.  When you use &lt;CODE&gt;eval&lt;/CODE&gt;, it uses &lt;CODE&gt;where&lt;/CODE&gt;-style logic ("WSL") which is slightly different than &lt;CODE&gt;search&lt;/CODE&gt;-style logic ("SSL").  WSL presumes that the right-hand-side ("RHS") s a field name, where as SSL presumes it is a string.  Furthermore, you cannot make SSL interpret the RHS as a field name HOWEVER you can make WSL interpret either.  The way to make WSL interpret the RHS as a string is to put it inside double-quotes, like &lt;CODE&gt;count(eval(date_month="august"))&lt;/CODE&gt;.  This is why we always teach people to use &lt;CODE&gt;search&lt;/CODE&gt; when RHS is a constant and use &lt;CODE&gt;where&lt;/CODE&gt; when RHS is a field name (even though you can make &lt;CODE&gt;where&lt;/CODE&gt; do either) and also to &lt;EM&gt;ALWAYS&lt;/EM&gt; use double-quotes when RHS is a constant, not a field name, even when (e.g. with &lt;CODE&gt;search&lt;/CODE&gt;) it is not necessary.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2017 18:22:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-the-conditional-count-in-my-stats-eval-search/m-p/290066#M87703</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-08-15T18:22:12Z</dc:date>
    </item>
  </channel>
</rss>

