<?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 How to write a search to return &amp;quot;PASS&amp;quot; if all search results for a field are PASS or PARTIAL_PASS, but return &amp;quot;FAIL&amp;quot; if at least one result is FAIL? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-return-quot-PASS-quot-if-all-search/m-p/178463#M51319</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have data in Splunk DB which could be presented with this simplified table (real table has about 100 lines):&lt;/P&gt;

&lt;P&gt;Test_Name......Test_Result&lt;BR /&gt;
test_1................PASS&lt;BR /&gt;
test_2................FAIL&lt;BR /&gt;
test_3................PARTIAL_PASS&lt;/P&gt;

&lt;P&gt;I need help in creating search string in Splunk which would give me the final result (in statistic tab) with the following logic:&lt;BR /&gt;
Final result: PASS if all Test_Result(s) were PASS or PARTIAL_PASS&lt;BR /&gt;
Final result: FAIL if at least one Test_Result were FAIL&lt;/P&gt;

&lt;P&gt;how search string should look like ?&lt;/P&gt;

&lt;P&gt;cheers,&lt;BR /&gt;
Milan&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 19:10:34 GMT</pubDate>
    <dc:creator>milande</dc:creator>
    <dc:date>2020-09-28T19:10:34Z</dc:date>
    <item>
      <title>How to write a search to return "PASS" if all search results for a field are PASS or PARTIAL_PASS, but return "FAIL" if at least one result is FAIL?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-return-quot-PASS-quot-if-all-search/m-p/178463#M51319</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have data in Splunk DB which could be presented with this simplified table (real table has about 100 lines):&lt;/P&gt;

&lt;P&gt;Test_Name......Test_Result&lt;BR /&gt;
test_1................PASS&lt;BR /&gt;
test_2................FAIL&lt;BR /&gt;
test_3................PARTIAL_PASS&lt;/P&gt;

&lt;P&gt;I need help in creating search string in Splunk which would give me the final result (in statistic tab) with the following logic:&lt;BR /&gt;
Final result: PASS if all Test_Result(s) were PASS or PARTIAL_PASS&lt;BR /&gt;
Final result: FAIL if at least one Test_Result were FAIL&lt;/P&gt;

&lt;P&gt;how search string should look like ?&lt;/P&gt;

&lt;P&gt;cheers,&lt;BR /&gt;
Milan&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 19:10:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-return-quot-PASS-quot-if-all-search/m-p/178463#M51319</guid>
      <dc:creator>milande</dc:creator>
      <dc:date>2020-09-28T19:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to return "PASS" if all search results for a field are PASS or PARTIAL_PASS, but return "FAIL" if at least one result is FAIL?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-return-quot-PASS-quot-if-all-search/m-p/178464#M51320</link>
      <description>&lt;P&gt;Let's approach it mathematically...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval numerical_result = case ( Test_Result = "PASS", 1 , Test_Result="PARTIAL_PASS", 2 , Test_Result="FAIL" , 3 , 1=1, 0 )
| stats max(numerical_result) as numerical_result
| eval result = case ( numerial_result = 1, "PASS", numerical_result =2, "PARTIAL_PASS", numerical_result = 3 , "FAIL" ,  1=1, "UNKNOWN" )
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So we make up a numerical equivalent to your PASS / PARTIAL_PASS / FAIL concepts and use &lt;CODE&gt;max()&lt;/CODE&gt; to hit your criteria.  Then we have to re-convert from numerics back to a textual representation.&lt;/P&gt;

&lt;P&gt;Maybe someone else has a better approach?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2015 17:09:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-return-quot-PASS-quot-if-all-search/m-p/178464#M51320</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2015-03-17T17:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to return "PASS" if all search results for a field are PASS or PARTIAL_PASS, but return "FAIL" if at least one result is FAIL?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-return-quot-PASS-quot-if-all-search/m-p/178465#M51321</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;... | stats count(eval(Test_Result="Fail")) as failed, count(eval(Test_Result!="Fail")) as notfailed | eval Final_Result=if(failed&amp;gt;0,"Fail",if(notfailed&amp;gt;0,"Passed","NA")) | table Final_Result
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will give a single row with fail if it finds even a single record of fail and calls them pass otherwise i.e. any not marked Fail are considered passed.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2015 00:06:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-return-quot-PASS-quot-if-all-search/m-p/178465#M51321</guid>
      <dc:creator>ramdaspr</dc:creator>
      <dc:date>2015-03-18T00:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to return "PASS" if all search results for a field are PASS or PARTIAL_PASS, but return "FAIL" if at least one result is FAIL?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-return-quot-PASS-quot-if-all-search/m-p/178466#M51322</link>
      <description>&lt;P&gt;@ dwaddle &lt;BR /&gt;
you approach seems also OK but for a sake of "shortness" I choose answer from "ramdaspr". &lt;BR /&gt;
Thanks dwaddle anyway! &lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2015 09:35:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-return-quot-PASS-quot-if-all-search/m-p/178466#M51322</guid>
      <dc:creator>milande</dc:creator>
      <dc:date>2015-03-18T09:35:24Z</dc:date>
    </item>
  </channel>
</rss>

