<?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 Can I even do this with an IF? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-I-even-do-this-with-an-IF/m-p/46063#M10997</link>
    <description>&lt;P&gt;Hi, multi value field called OverallStatus - states are On Track, Marginal, Critical. Another field ID, contains a unique value to count.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count(ID) AS Event count(eval(OverallStatus="On Track")) AS OnTrack count(eval(OverallStatus="Marginal")) AS Marginal count(eval(OverallStatus="Critical")) AS Red by Project ID
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is the metric: ( basically a Red - Yellow - Green )&lt;/P&gt;

&lt;P&gt;Green = 80% or more projects are green and none are Red. Yellow = 70% - 79% projects are green or 1 – 20% are Red.  Red = under 70% projects are green or over 20% are Red.&lt;/P&gt;

&lt;P&gt;I just can't get my head around the "IF" ... Really only need to show this back in a Red Yellow or Green.&lt;/P&gt;

&lt;P&gt;Any help or direction, would be greatly appreciated!&lt;/P&gt;

&lt;P&gt;Cheers...&lt;/P&gt;</description>
    <pubDate>Mon, 26 Aug 2013 12:56:29 GMT</pubDate>
    <dc:creator>edenzler</dc:creator>
    <dc:date>2013-08-26T12:56:29Z</dc:date>
    <item>
      <title>Can I even do this with an IF?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-even-do-this-with-an-IF/m-p/46063#M10997</link>
      <description>&lt;P&gt;Hi, multi value field called OverallStatus - states are On Track, Marginal, Critical. Another field ID, contains a unique value to count.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count(ID) AS Event count(eval(OverallStatus="On Track")) AS OnTrack count(eval(OverallStatus="Marginal")) AS Marginal count(eval(OverallStatus="Critical")) AS Red by Project ID
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is the metric: ( basically a Red - Yellow - Green )&lt;/P&gt;

&lt;P&gt;Green = 80% or more projects are green and none are Red. Yellow = 70% - 79% projects are green or 1 – 20% are Red.  Red = under 70% projects are green or over 20% are Red.&lt;/P&gt;

&lt;P&gt;I just can't get my head around the "IF" ... Really only need to show this back in a Red Yellow or Green.&lt;/P&gt;

&lt;P&gt;Any help or direction, would be greatly appreciated!&lt;/P&gt;

&lt;P&gt;Cheers...&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2013 12:56:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-even-do-this-with-an-IF/m-p/46063#M10997</guid>
      <dc:creator>edenzler</dc:creator>
      <dc:date>2013-08-26T12:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: Can I even do this with an IF?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-even-do-this-with-an-IF/m-p/46064#M10998</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere
| stats count(ID) AS Event count(eval(OverallStatus="On Track")) AS OnTrack count(eval(OverallStatus="Marginal")) AS 
    Marginal count(eval(OverallStatus="Critical")) AS Critical by ProjectID
| eval percentOnTrack = OnTrack * 100 / (OnTrack + Marginal + Critical)
| eval percentMarginal = Marginal * 100 / (OnTrack + Marginal + Critical)
| eval percentCritical = Critical * 100 / (OnTrack + Marginal + Critical)
| eval Status = case(percentOnTrack &amp;gt; 79 AND percentCritical = 0, "Green",
                     percentOnTrack &amp;gt; 69 AND percentOnTrack &amp;lt; 80, "Yellow",
                     percentCritical &amp;gt; 0 AND percentCritical &amp;lt; 21, "Yellow",
                     percentOnTrack &amp;lt; 70,"Red",
                     percentCritical &amp;gt; 20,"Red",
                     1=1,"Unknown")
| table ProjectID Status percentOnTrack percentMarginal percentCritical OnTrack Marginal Critical
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You could do it with an &lt;CODE&gt;if&lt;/CODE&gt;, but I just think it is easier with a &lt;CODE&gt;case&lt;/CODE&gt; function.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2013 20:58:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-even-do-this-with-an-IF/m-p/46064#M10998</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-08-26T20:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: Can I even do this with an IF?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-even-do-this-with-an-IF/m-p/46065#M10999</link>
      <description>&lt;P&gt;Thanks Iguinn! I managed to do it this way, wondering which one would be better?&lt;/P&gt;

&lt;P&gt;| stats count(ID) AS Event count(eval(OverallStatus="On Track")) AS Green count(eval(OverallStatus="Marginal")) AS Yellow count(eval(OverallStatus="Critical")) AS Red by Product&lt;BR /&gt;
| eval Green1=Green / Event * 100&lt;BR /&gt;
| eval Yellow1=Yellow / Event * 100&lt;BR /&gt;
| eval Red1=Red / Event * 100&lt;BR /&gt;
| table Product Event Red Yellow Green Red1 Yellow1 Green1 | eval "Overall Status" = if (Green1 &amp;lt;= 70 OR Red1 &amp;gt;= 20, "Red",  if (Green1 &amp;gt;= 70 AND Green1 &amp;lt;= 79.9 AND Red1 &amp;lt;= 20, "Yellow", if (Green1 &amp;gt;= 80 AND Red &amp;lt;= 0, "Green","Unknown")))&lt;/P&gt;

&lt;P&gt;Cheers!&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2013 21:30:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-even-do-this-with-an-IF/m-p/46065#M10999</guid>
      <dc:creator>edenzler</dc:creator>
      <dc:date>2013-08-26T21:30:08Z</dc:date>
    </item>
    <item>
      <title>Re: Can I even do this with an IF?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-even-do-this-with-an-IF/m-p/46066#M11000</link>
      <description>&lt;P&gt;I don't know which one is faster, I just like the &lt;CODE&gt;case&lt;/CODE&gt; function because I find it easier to read and debug!&lt;/P&gt;

&lt;P&gt;You could try them both and look at the search job inspector for the run time... that's not perfectly accurate because search load varies moment to moment - but if there is a big difference you will see it.  (Search job inspector = the box with the "i" in case you didn't know)&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2013 17:46:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-even-do-this-with-an-IF/m-p/46066#M11000</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-08-27T17:46:40Z</dc:date>
    </item>
  </channel>
</rss>

