<?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(eval) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/666459#M228634</link>
    <description>&lt;P&gt;Isn't this exactly what I posted in&amp;nbsp;&lt;A href="https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/665764/highlight/true#M228420?" target="_blank"&gt;https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/665764/highlight/true#M228420?&lt;/A&gt;&amp;nbsp; Splunk doesn't really store boolean values.&lt;/P&gt;</description>
    <pubDate>Fri, 27 Oct 2023 06:23:56 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2023-10-27T06:23:56Z</dc:date>
    <item>
      <title>conditional count(eval)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/661076#M228245</link>
      <description>&lt;P&gt;Hi community,&lt;/P&gt;&lt;P&gt;| eval ycw = strftime(_time, "%Y_%U")&lt;BR /&gt;| stats count(eval("FieldA"="True")) as FieldA_True,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; count(eval('FieldB'="True")) as FieldB_True,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; count(eval('FieldC'="True")) as FieldC_True&lt;BR /&gt;by ycw&lt;BR /&gt;| table ycw, FieldA_True, FieldB_True, FieldC_True&lt;/P&gt;&lt;P&gt;I get 0 result even though there is data. Could anyone please suggest a correct query?&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 18:03:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/661076#M228245</guid>
      <dc:creator>learningquery</dc:creator>
      <dc:date>2023-10-17T18:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: conditional count(eval)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/661089#M228247</link>
      <description>&lt;P&gt;I've added some fake data before the SPL you provided and when I run it I get results&amp;nbsp; like the below screenshot. It's hard to say what is going on in your environment and with your data but I would tend to think either the base search returned nothing or your fields (FieldA,&amp;nbsp;FieldB,&amp;nbsp;FieldC) don't exist in the data returned from the base search.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=300
| eval _time=_time-(86400*(random() % 61))
| eval FieldA=if(random() % 2==1,"True", "False")
| eval FieldB=if(random() % 2==1,"True", "False")
| eval FieldC=if(random() % 2==1,"True", "False")
```^^^^ Fake data added by me ^^^^```
| eval ycw = strftime(_time, "%Y_%U")
| stats count(eval('FieldA'="True")) as FieldA_True, count(eval('FieldB'="True")) as FieldB_True, count(eval('FieldC'="True")) as FieldC_True by ycw
| table ycw, FieldA_True, FieldB_True, FieldC_True&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 996px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/27627iBC794B2DD99C4BC1/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 19:06:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/661089#M228247</guid>
      <dc:creator>fredclown</dc:creator>
      <dc:date>2023-10-17T19:06:44Z</dc:date>
    </item>
    <item>
      <title>Re: conditional count(eval)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/661090#M228248</link>
      <description>&lt;P&gt;Confirm the ycw field has values.&amp;nbsp; If ycw is null then the &lt;FONT face="courier new,courier"&gt;stats&lt;/FONT&gt; command will return no results - because there are no values by which to group the stats.&lt;/P&gt;&lt;P&gt;Also, the evals should not have the field names in double quotes because that treats them a literal strings rather than as field names.&amp;nbsp; Use single quotes or no quotes around field names.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 19:05:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/661090#M228248</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-10-17T19:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: conditional count(eval)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/661245#M228289</link>
      <description>&lt;P&gt;Based on the search given ycw will always have a value as it is derived from _time and every event has an _time.&lt;/P&gt;&lt;P&gt;The second part is correct. I too noticed that and corrected the double quotes in the eval in my answer.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 16:58:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/661245#M228289</guid>
      <dc:creator>fredclown</dc:creator>
      <dc:date>2023-10-18T16:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: conditional count(eval)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/665662#M228379</link>
      <description>&lt;P&gt;Thanks for providing the hints. I tried both the changes eval and random command it did not work unfortunately. While I am sure the data exists.&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-10-20 at 11.24.24.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/27676iB00DB939F34B97FA/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2023-10-20 at 11.24.24.png" alt="Screenshot 2023-10-20 at 11.24.24.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2023 09:26:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/665662#M228379</guid>
      <dc:creator>learningquery</dc:creator>
      <dc:date>2023-10-20T09:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: conditional count(eval)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/665737#M228405</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;unfortunately. While I am sure the data exists.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;By "data exists" do you mean some values of field "Infra Finding" are string "Yes", etc.? &amp;nbsp;Can you show sample output of&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;earliest=-10w latest=now LOB=HEC search_name!=null
| eval ycw = strftime(_time, "%Y_%U")
| fields ycw "Infra Finding" "OS Finding" "App Finding"
| stats values(*) as * by ycw&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Oct 2023 08:50:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/665737#M228405</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-10-21T08:50:02Z</dc:date>
    </item>
    <item>
      <title>Re: conditional count(eval)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/665759#M228416</link>
      <description>&lt;P&gt;Thanks for the hint. Attached is the result I get. But want the total count of all TRUE cases listed per calendar week in numbers and also in % (I don't want the FALSE as result ). The attached .xls shows what I am looking for with example numbers&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-10-20 at 11.24.24.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/27687i1C5B96CB58443F33/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2023-10-20 at 11.24.24.png" alt="Screenshot 2023-10-20 at 11.24.24.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-10-21 at 21.23.03.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/27688i456C370372DEB1A1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2023-10-21 at 21.23.03.png" alt="Screenshot 2023-10-21 at 21.23.03.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Sat, 21 Oct 2023 19:23:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/665759#M228416</guid>
      <dc:creator>learningquery</dc:creator>
      <dc:date>2023-10-21T19:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: conditional count(eval)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/665761#M228417</link>
      <description>&lt;P&gt;Sorry, now I put the correct result (Pl ignore the previous result)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-10-21 at 21.27.49.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/27689i678E1AFE78C7A0B1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2023-10-21 at 21.27.49.png" alt="Screenshot 2023-10-21 at 21.27.49.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Sat, 21 Oct 2023 19:27:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/665761#M228417</guid>
      <dc:creator>learningquery</dc:creator>
      <dc:date>2023-10-21T19:27:59Z</dc:date>
    </item>
    <item>
      <title>Re: conditional count(eval)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/665764#M228420</link>
      <description>&lt;P&gt;Pro tip: Post data and output in text. &amp;nbsp;It is much easier for volunteers.&lt;/P&gt;&lt;P&gt;So, the fields do NOT have values "True" as your mock code has implied. &amp;nbsp;They have values "true". &amp;nbsp;If you haven't grasped this, Splunk stores most data in string tokenized strings and numeric values. &amp;nbsp;Have you tried this?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval ycw = strftime(_time, "%Y_%U")
| stats count(eval('FieldA'="true")) as FieldA_True,
              count(eval('FieldB'="true")) as FieldB_True,
              count(eval('FieldC'="true")) as FieldC_True
by ycw
| table ycw, FieldA_True, FieldB_True, FieldC_True&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 21 Oct 2023 20:38:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/665764#M228420</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-10-21T20:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: conditional count(eval)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/666457#M228632</link>
      <description>&lt;P&gt;I figured out the minor error was - "True" needs to be "true", as the value returns a boolean.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2023 06:20:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/666457#M228632</guid>
      <dc:creator>learningquery</dc:creator>
      <dc:date>2023-10-27T06:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: conditional count(eval)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/666459#M228634</link>
      <description>&lt;P&gt;Isn't this exactly what I posted in&amp;nbsp;&lt;A href="https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/665764/highlight/true#M228420?" target="_blank"&gt;https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/665764/highlight/true#M228420?&lt;/A&gt;&amp;nbsp; Splunk doesn't really store boolean values.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2023 06:23:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/666459#M228634</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-10-27T06:23:56Z</dc:date>
    </item>
    <item>
      <title>Re: conditional count(eval)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/666464#M228635</link>
      <description>&lt;P&gt;absolutely,&amp;nbsp; I was too beginner to grasp it!&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2023 06:36:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/conditional-count-eval/m-p/666464#M228635</guid>
      <dc:creator>learningquery</dc:creator>
      <dc:date>2023-10-27T06:36:40Z</dc:date>
    </item>
  </channel>
</rss>

