<?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: Nested IF Structure - Assign Values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Nested-IF-Structure-Assign-Values/m-p/179012#M51539</link>
    <description>&lt;P&gt;Hi Mark,&lt;BR /&gt;
it had a typo, the double quote in front of End was superfluous&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| eval PenatlyPoints=if(&amp;lt;time&amp;gt; &amp;lt; &amp;lt;timelimit&amp;gt; ,if(match(_raw,".*End Program.*"), "1","100"), " ")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;sorry for the confusion.&lt;/P&gt;

&lt;P&gt;The match function returns true only if the filed contains a value which is matched by the regular expression, in the example above it will be true if the string &lt;STRONG&gt;End Program&lt;/STRONG&gt; is found somewhere in the field _raw (the complete event)&lt;/P&gt;</description>
    <pubDate>Thu, 08 Jan 2015 12:14:07 GMT</pubDate>
    <dc:creator>FritzWittwer_ol</dc:creator>
    <dc:date>2015-01-08T12:14:07Z</dc:date>
    <item>
      <title>Nested IF Structure - Assign Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Nested-IF-Structure-Assign-Values/m-p/179007#M51534</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
We have a nested IF structure and we want to use it to assign a value to a field called PenaltyPoints1&lt;/P&gt;

&lt;P&gt;Firstly it checks to see if the current time meets the required minimum time, if that's true then it should search for the phrase "End Program" and if it finds it, PenaltyPoints1 should be set a value of 0, if it cannot find it, then it should be assigned a value of 100.  &lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 10:59:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Nested-IF-Structure-Assign-Values/m-p/179007#M51534</guid>
      <dc:creator>markthompson</dc:creator>
      <dc:date>2015-01-08T10:59:52Z</dc:date>
    </item>
    <item>
      <title>Re: Nested IF Structure - Assign Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Nested-IF-Structure-Assign-Values/m-p/179008#M51535</link>
      <description>&lt;P&gt;you can nest ifs just like any other function, e.g.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| eval PenatlyPoints=if(&amp;lt;time&amp;gt; &amp;lt; &amp;lt;timelimit&amp;gt; ,if(match(&amp;lt;field&amp;gt;,".*"End Program.*"), "1","100"), " ")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;see also &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.1.5/SearchReference/CommonEvalFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/6.1.5/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 11:50:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Nested-IF-Structure-Assign-Values/m-p/179008#M51535</guid>
      <dc:creator>FritzWittwer_ol</dc:creator>
      <dc:date>2015-01-08T11:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: Nested IF Structure - Assign Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Nested-IF-Structure-Assign-Values/m-p/179009#M51536</link>
      <description>&lt;P&gt;Hi FritzWittwer,&lt;BR /&gt;
Unfortunately, the "End Program" isn't in a field, it's in the content of the Event.&lt;/P&gt;

&lt;P&gt;Thanks for the quick response.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 11:58:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Nested-IF-Structure-Assign-Values/m-p/179009#M51536</guid>
      <dc:creator>markthompson</dc:creator>
      <dc:date>2015-01-08T11:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: Nested IF Structure - Assign Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Nested-IF-Structure-Assign-Values/m-p/179010#M51537</link>
      <description>&lt;P&gt;Hi Mark,&lt;BR /&gt;
in this case you can just use the filed named &lt;CODE&gt;_raw&lt;/CODE&gt; this contains the whole raw event data.&lt;/P&gt;

&lt;P&gt;Fritz&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 12:01:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Nested-IF-Structure-Assign-Values/m-p/179010#M51537</guid>
      <dc:creator>FritzWittwer_ol</dc:creator>
      <dc:date>2015-01-08T12:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: Nested IF Structure - Assign Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Nested-IF-Structure-Assign-Values/m-p/179011#M51538</link>
      <description>&lt;P&gt;It also appears to error with "Unbalanced Quotes", can you use "event" as a field?  Also, Could you explain the match(field, ".&lt;EM&gt;"End Program.&lt;/EM&gt;" as it seems to me you're searching for "End Program" as opposed to End Program&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 12:05:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Nested-IF-Structure-Assign-Values/m-p/179011#M51538</guid>
      <dc:creator>markthompson</dc:creator>
      <dc:date>2015-01-08T12:05:28Z</dc:date>
    </item>
    <item>
      <title>Re: Nested IF Structure - Assign Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Nested-IF-Structure-Assign-Values/m-p/179012#M51539</link>
      <description>&lt;P&gt;Hi Mark,&lt;BR /&gt;
it had a typo, the double quote in front of End was superfluous&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| eval PenatlyPoints=if(&amp;lt;time&amp;gt; &amp;lt; &amp;lt;timelimit&amp;gt; ,if(match(_raw,".*End Program.*"), "1","100"), " ")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;sorry for the confusion.&lt;/P&gt;

&lt;P&gt;The match function returns true only if the filed contains a value which is matched by the regular expression, in the example above it will be true if the string &lt;STRONG&gt;End Program&lt;/STRONG&gt; is found somewhere in the field _raw (the complete event)&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 12:14:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Nested-IF-Structure-Assign-Values/m-p/179012#M51539</guid>
      <dc:creator>FritzWittwer_ol</dc:creator>
      <dc:date>2015-01-08T12:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: Nested IF Structure - Assign Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Nested-IF-Structure-Assign-Values/m-p/179013#M51540</link>
      <description>&lt;P&gt;Hi FritzWittwer, &lt;BR /&gt;
Thanks for that, I've changed the 1 to a 0 as they should not receive any penaltypoints for finishing the job at the right time. &lt;/P&gt;

&lt;P&gt;I'll mark it as the answer now, but first would you mind converting your comment to an answer?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 12:31:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Nested-IF-Structure-Assign-Values/m-p/179013#M51540</guid>
      <dc:creator>markthompson</dc:creator>
      <dc:date>2015-01-08T12:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: Nested IF Structure - Assign Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Nested-IF-Structure-Assign-Values/m-p/179014#M51541</link>
      <description>&lt;P&gt;Hi Mark,&lt;BR /&gt;
so the final solution is&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| eval PenaltyPoints=if(&amp;lt;time&amp;gt; &amp;lt; &amp;lt;timelimit&amp;gt; ,if(match(_raw,".*End Program.*"), "0","100"), " ")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;of course &lt;STRONG&gt;time&lt;/STRONG&gt; and &lt;STRONG&gt;timelimit&lt;/STRONG&gt; are just placeholders&lt;/P&gt;

&lt;P&gt;Fritz&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 12:35:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Nested-IF-Structure-Assign-Values/m-p/179014#M51541</guid>
      <dc:creator>FritzWittwer_ol</dc:creator>
      <dc:date>2015-01-08T12:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: Nested IF Structure - Assign Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Nested-IF-Structure-Assign-Values/m-p/179015#M51542</link>
      <description>&lt;P&gt;Hi FtizWittwer, Don't suppose you know anything about eventstats.  &lt;/P&gt;

&lt;P&gt;&lt;A href="http://answers.splunk.com/answers/208180/eventstats-count-function.html"&gt;http://answers.splunk.com/answers/208180/eventstats-count-function.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 13:26:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Nested-IF-Structure-Assign-Values/m-p/179015#M51542</guid>
      <dc:creator>markthompson</dc:creator>
      <dc:date>2015-01-08T13:26:09Z</dc:date>
    </item>
  </channel>
</rss>

