<?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: Count Field values based on different criteria in Monitoring Splunk</title>
    <link>https://community.splunk.com/t5/Monitoring-Splunk/Count-Field-values-based-on-different-criteria/m-p/541918#M4799</link>
    <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232004"&gt;@andres91302&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Look like dc(eval()) returns 1 always.&lt;BR /&gt;Try this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eventstats count as TOTAL
| where match(SEGT, "\d+") 
| stats dc(SEGT) as RES, latest(TOTAL) as TOTAL, count(SEGT) as SEGT_CNT
| eval Empty = TOTAL - SEGT_CNT
| table Empty, RES&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this reply helps you, an upvote/like would be appreciated.&lt;/P&gt;</description>
    <pubDate>Tue, 02 Mar 2021 09:16:53 GMT</pubDate>
    <dc:creator>manjunathmeti</dc:creator>
    <dc:date>2021-03-02T09:16:53Z</dc:date>
    <item>
      <title>Count Field values based on different criteria</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/Count-Field-values-based-on-different-criteria/m-p/541794#M4798</link>
      <description>&lt;P&gt;Hello Guys! Thank you in advance for your help ,&lt;/P&gt;&lt;P&gt;My data: Events that contain a field named SEGT which may be empty or may contain a unique number that can be repeated for example: SEGT=[1,1," ", 2, " ", 4, 4587, 7856, " "]&amp;nbsp;&lt;/P&gt;&lt;P&gt;what I am trying to do: Create a table with 2 columns first&amp;nbsp;column named Empty which will count all the event with the field SEGT="" and second&amp;nbsp;column named RES with all the distinct count of the values in the field SEGT that are not empty.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Code:&amp;nbsp;&lt;BR /&gt;| Search&lt;BR /&gt;| stats count(eval(SEGT="")) As Empty&lt;BR /&gt;| stats dc(eval(SEGT!="")) As RES&lt;BR /&gt;| Table&amp;nbsp;Empty&amp;nbsp;&amp;nbsp;RES&lt;BR /&gt;But I'm not getting the results that I want, and I will really appreciate if you guys could help me out!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 15:06:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/Count-Field-values-based-on-different-criteria/m-p/541794#M4798</guid>
      <dc:creator>andres91302</dc:creator>
      <dc:date>2021-03-01T15:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: Count Field values based on different criteria</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/Count-Field-values-based-on-different-criteria/m-p/541918#M4799</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232004"&gt;@andres91302&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Look like dc(eval()) returns 1 always.&lt;BR /&gt;Try this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eventstats count as TOTAL
| where match(SEGT, "\d+") 
| stats dc(SEGT) as RES, latest(TOTAL) as TOTAL, count(SEGT) as SEGT_CNT
| eval Empty = TOTAL - SEGT_CNT
| table Empty, RES&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this reply helps you, an upvote/like would be appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 09:16:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/Count-Field-values-based-on-different-criteria/m-p/541918#M4799</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2021-03-02T09:16:53Z</dc:date>
    </item>
    <item>
      <title>Re: Count Field values based on different criteria</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/Count-Field-values-based-on-different-criteria/m-p/541925#M4800</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232004"&gt;@andres91302&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did some correction in your search. Can you please try below search?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;YOUR_SEARCH
| stats count(eval(trim(SEGT)=="")) As Empty, dc(eval(tonumber(SEGT))) as RES
| table Empty  RES&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample Search:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults | eval SEGT="1,1, ,2, ,4,4587,7856, ", SEGT=split(SEGT,","), OtherData="hello" | mvexpand SEGT
| rename comment as "Upto Now is sample data only"
| stats count(eval(trim(SEGT)=="")) As Empty, dc(eval(tonumber(SEGT))) as RES
| table Empty  RES&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 02 Mar 2021 10:00:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/Count-Field-values-based-on-different-criteria/m-p/541925#M4800</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2021-03-02T10:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: Count Field values based on different criteria</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/Count-Field-values-based-on-different-criteria/m-p/544100#M4878</link>
      <description>Hi kamlesh_vaghela thank you for your reply (You look great with those glasses by the way) would you be so kind to explain why are you using count(eval(trim(SEGT)=="")) the function trim? and dc(eval(tonumber(SEGT))) tonumber? what do they do? I will be forever happy</description>
      <pubDate>Wed, 17 Mar 2021 03:00:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/Count-Field-values-based-on-different-criteria/m-p/544100#M4878</guid>
      <dc:creator>andres91302</dc:creator>
      <dc:date>2021-03-17T03:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: Count Field values based on different criteria</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/Count-Field-values-based-on-different-criteria/m-p/544101#M4879</link>
      <description>hello manjunathmeti thank you for being so kind and helping me solving this task. would you please explain what does every line in your code do? Im new to splunk and I cant seem to find a good source of documentation to have as a reference... what does | where match(SEGT, "\d+") do? and why did you use the funtion latest() THANKS A LOT MY FRIEND</description>
      <pubDate>Wed, 17 Mar 2021 03:05:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/Count-Field-values-based-on-different-criteria/m-p/544101#M4879</guid>
      <dc:creator>andres91302</dc:creator>
      <dc:date>2021-03-17T03:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: Count Field values based on different criteria</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/Count-Field-values-based-on-different-criteria/m-p/544123#M4881</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232004"&gt;@andres91302&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eventstats count as TOTAL&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;--- counts the total number of events retaining all the raw events. &lt;STRONG&gt;TOTAL&lt;/STRONG&gt; value will be the same for all the rows.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where match(SEGT, "\d+")&lt;/LI-CODE&gt;&lt;P&gt;---&amp;nbsp; &lt;STRONG&gt;where&lt;/STRONG&gt; command evaluates match function&amp;nbsp;&lt;SPAN&gt;to filter search results. T&lt;/SPAN&gt;&lt;SPAN&gt;he &lt;STRONG&gt;match&lt;/STRONG&gt; function returns TRUE if the regular expression finds a match against any substring of the string value. In this case a number in field &lt;STRONG&gt;SEGT&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats dc(SEGT) as RES, latest(TOTAL) as TOTAL, count(SEGT) as SEGT_CNT&lt;/LI-CODE&gt;&lt;P&gt;---&amp;nbsp;&lt;STRONG&gt;latest&lt;/STRONG&gt; returns&lt;SPAN&gt;&amp;nbsp;the chronologically latest seen occurrence of a value in &lt;STRONG&gt;TOTAL&lt;/STRONG&gt;. We just need the first/latest value as the &lt;STRONG&gt;TOTAL&lt;/STRONG&gt; is the same for all the rows.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Mar 2021 06:56:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/Count-Field-values-based-on-different-criteria/m-p/544123#M4881</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2021-03-17T06:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: Count Field values based on different criteria</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/Count-Field-values-based-on-different-criteria/m-p/544332#M4887</link>
      <description>&lt;P&gt;Oh wow! THANK YOU SO SO MUCH for this.... you have no idea what it means to me, i's because people like you that I belive in a better world ahead. thank you for your detailed explanation, I wanna praise you!&lt;/P&gt;</description>
      <pubDate>Thu, 18 Mar 2021 13:45:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/Count-Field-values-based-on-different-criteria/m-p/544332#M4887</guid>
      <dc:creator>andres91302</dc:creator>
      <dc:date>2021-03-18T13:45:03Z</dc:date>
    </item>
  </channel>
</rss>

