<?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: Conditional Statements in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Conditional-Statements/m-p/55210#M13487</link>
    <description>&lt;P&gt;Your best bet is to use stats. Here you may want to use max() as an aggregator.&lt;/P&gt;

&lt;P&gt;For example, append to your search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats max(Result) as Result by Location
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can always use eval. For example, if you only care about Result being exactly 100:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats max(eval(if(Result==100, 100, 0))) as Result by Location
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 19 May 2012 04:06:05 GMT</pubDate>
    <dc:creator>Stephen_Sorkin</dc:creator>
    <dc:date>2012-05-19T04:06:05Z</dc:date>
    <item>
      <title>Conditional Statements</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-Statements/m-p/55209#M13486</link>
      <description>&lt;P&gt;Hi Splunkbase, &lt;/P&gt;

&lt;P&gt;I was wondering if someone would be able to assist with a problem that I am trying to get my head around, I am not able to get the desired results. Here is my problem...&lt;/P&gt;

&lt;P&gt;Say I have some events, for example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Device Location Result
a123   loc1     0  
b123   loc1     100
c123   loc1     0
----   ----     ------
a456   loc2     0
b456   loc2     0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to group these devices by location, and then output a value dependant on the following condition... If for &lt;STRONG&gt;&lt;EM&gt;any&lt;/EM&gt;&lt;/STRONG&gt; device in a single location, the result is "100" then the output value for the whole location (new field) will be 100, or if all the devices in a single location have a result of "0" then I would like to output 0 to the new field.&lt;/P&gt;

&lt;P&gt;So my expected results would be something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Location Result
loc1     100
loc2     0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or something to that effect. &lt;/P&gt;

&lt;P&gt;Any thoughts/suggestions.&lt;/P&gt;

&lt;P&gt;Regards,&lt;/P&gt;

&lt;P&gt;Matt&lt;/P&gt;</description>
      <pubDate>Fri, 18 May 2012 14:08:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-Statements/m-p/55209#M13486</guid>
      <dc:creator>MHibbin</dc:creator>
      <dc:date>2012-05-18T14:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Statements</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-Statements/m-p/55210#M13487</link>
      <description>&lt;P&gt;Your best bet is to use stats. Here you may want to use max() as an aggregator.&lt;/P&gt;

&lt;P&gt;For example, append to your search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats max(Result) as Result by Location
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can always use eval. For example, if you only care about Result being exactly 100:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats max(eval(if(Result==100, 100, 0))) as Result by Location
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 19 May 2012 04:06:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-Statements/m-p/55210#M13487</guid>
      <dc:creator>Stephen_Sorkin</dc:creator>
      <dc:date>2012-05-19T04:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Statements</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-Statements/m-p/55211#M13488</link>
      <description>&lt;P&gt;Ha! Always the simplest solution that I overlooked!&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Sat, 19 May 2012 11:05:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-Statements/m-p/55211#M13488</guid>
      <dc:creator>MHibbin</dc:creator>
      <dc:date>2012-05-19T11:05:55Z</dc:date>
    </item>
  </channel>
</rss>

