<?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 Count Single Occurrence Based On Value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Count-Single-Occurrence-Based-On-Value/m-p/523728#M147737</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need some help with the below. We have multiple entries for a single IP that has multiple results as the Status Field - I want to know 'How many Hosts Passed, How many Failed and how any were Not Attempted'&lt;/P&gt;&lt;TABLE border="1" width="45.40654479562126%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;IP&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;Status&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;10.50.50.50&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;Passed&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="17px"&gt;10.50.50.50&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="17px"&gt;&lt;P&gt;Failed&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;10.50.50.50&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;Not Attempted&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;10.60.60.60&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;Passed&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;10.60.60.60&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;Failed&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;10.70.70.70&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;Passed&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I simply do Stats count by Status, i get the below:&lt;/P&gt;&lt;P&gt;Passed: 3&lt;BR /&gt;Failed: 2&lt;BR /&gt;Not Attempted: 1&lt;/P&gt;&lt;P&gt;But i know there are only 3 IP's so i need a way to know if a host Passed once - Mark it as Passed only&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Count if an IP has a Status of Passed, mark it as 'Passed'&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;If an IP has a status of Failed and Failed only, then count it as failed&lt;/LI&gt;&lt;LI&gt;If an IP has a status of Not Attempted and Not Attempted only then mark it as Not Attempted&amp;nbsp; &amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;So the output should be the same as the below (Because once an IP has a 'Passed', it shouldn't count towards the other values):&lt;BR /&gt;Passed: 3&lt;BR /&gt;Failed: 0&lt;BR /&gt;Not Attempted: 0&lt;/P&gt;&lt;P&gt;Hope the above makes sense and appreciate the help!&lt;/P&gt;</description>
    <pubDate>Thu, 08 Oct 2020 15:14:31 GMT</pubDate>
    <dc:creator>fward92</dc:creator>
    <dc:date>2020-10-08T15:14:31Z</dc:date>
    <item>
      <title>Count Single Occurrence Based On Value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-Single-Occurrence-Based-On-Value/m-p/523728#M147737</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need some help with the below. We have multiple entries for a single IP that has multiple results as the Status Field - I want to know 'How many Hosts Passed, How many Failed and how any were Not Attempted'&lt;/P&gt;&lt;TABLE border="1" width="45.40654479562126%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;IP&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;Status&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;10.50.50.50&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;Passed&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="17px"&gt;10.50.50.50&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="17px"&gt;&lt;P&gt;Failed&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;10.50.50.50&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;Not Attempted&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;10.60.60.60&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;Passed&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;10.60.60.60&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;Failed&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;10.70.70.70&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;Passed&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I simply do Stats count by Status, i get the below:&lt;/P&gt;&lt;P&gt;Passed: 3&lt;BR /&gt;Failed: 2&lt;BR /&gt;Not Attempted: 1&lt;/P&gt;&lt;P&gt;But i know there are only 3 IP's so i need a way to know if a host Passed once - Mark it as Passed only&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Count if an IP has a Status of Passed, mark it as 'Passed'&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;If an IP has a status of Failed and Failed only, then count it as failed&lt;/LI&gt;&lt;LI&gt;If an IP has a status of Not Attempted and Not Attempted only then mark it as Not Attempted&amp;nbsp; &amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;So the output should be the same as the below (Because once an IP has a 'Passed', it shouldn't count towards the other values):&lt;BR /&gt;Passed: 3&lt;BR /&gt;Failed: 0&lt;BR /&gt;Not Attempted: 0&lt;/P&gt;&lt;P&gt;Hope the above makes sense and appreciate the help!&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 15:14:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-Single-Occurrence-Based-On-Value/m-p/523728#M147737</guid>
      <dc:creator>fward92</dc:creator>
      <dc:date>2020-10-08T15:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Count Single Occurrence Based On Value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-Single-Occurrence-Based-On-Value/m-p/523730#M147738</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/227323"&gt;@fward92&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;if it's acceptable for you to take the last value for each IP, try something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;your_search
| stats last(Status) AS Status BY IP
| stats count BY Status&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 15:21:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-Single-Occurrence-Based-On-Value/m-p/523730#M147738</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-10-08T15:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: Count Single Occurrence Based On Value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-Single-Occurrence-Based-On-Value/m-p/523733#M147740</link>
      <description>&lt;P&gt;Unfortunately, the values in the Status field appear in different orders - Is there a way to do multiple eval commands that take both a 'contains failed' AND Does not contain 'Passed' AS Count_Failed&lt;BR /&gt;&lt;BR /&gt;Something like that might work&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 15:30:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-Single-Occurrence-Based-On-Value/m-p/523733#M147740</guid>
      <dc:creator>fward92</dc:creator>
      <dc:date>2020-10-08T15:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: Count Single Occurrence Based On Value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-Single-Occurrence-Based-On-Value/m-p/523854#M147794</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/227323"&gt;@fward92&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I haven't your data so I cannot test your conditions, but anyway, you can apply the approch of this sample:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=_internal
| stats values(source) AS source dc(source) AS dc_source BY user
| eval status=if(dc_source=1 OR match(source,"scripted"),"OK","NOK")&lt;/LI-CODE&gt;&lt;P&gt;In few words:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;if you have only one value you take it,&lt;/LI&gt;&lt;LI&gt;if you have more values you takes the ones that match a word,&lt;/LI&gt;&lt;LI&gt;then you can exclude the "NOK".&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2020 06:33:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-Single-Occurrence-Based-On-Value/m-p/523854#M147794</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-10-09T06:33:06Z</dc:date>
    </item>
  </channel>
</rss>

