<?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: Search using IF statement in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Search-using-IF-statement/m-p/524286#M147909</link>
    <description>&lt;P&gt;Thanks for the concise example of if expression.&lt;/P&gt;</description>
    <pubDate>Mon, 12 Oct 2020 23:05:55 GMT</pubDate>
    <dc:creator>yshen</dc:creator>
    <dc:date>2020-10-12T23:05:55Z</dc:date>
    <item>
      <title>Search using IF statement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-using-IF-statement/m-p/496383#M138331</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;Could you please help me with " if "query to search  a condition is true  then need to display some values from json format .&lt;BR /&gt;
 please i m brand new to splunk ..&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 07:48:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-using-IF-statement/m-p/496383#M138331</guid>
      <dc:creator>tech_soul</dc:creator>
      <dc:date>2019-10-01T07:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: Search using IF statement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-using-IF-statement/m-p/496384#M138332</link>
      <description>&lt;P&gt;Hi tech_soul,&lt;BR /&gt;
without othe information is difficoult to help you! could you share more information?&lt;/P&gt;

&lt;P&gt;Anyway, you can use the if condition in an eval command to set a variable to use for searches, for additioan information see &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.1/SearchReference/ConditionalFunctions"&gt;https://docs.splunk.com/Documentation/Splunk/7.3.1/SearchReference/ConditionalFunctions&lt;/A&gt; .&lt;/P&gt;

&lt;P&gt;E.g. if I want to set a value OK if a field has a value less than 100 and NOK if the value is more than 100, you could create a search like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_index
| eval my_check=if(my_field&amp;gt;100,"NOK","OK")
| table _time my_check
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then you can use this value for additional conditions as search or where.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 08:00:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-using-IF-statement/m-p/496384#M138332</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-10-01T08:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: Search using IF statement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-using-IF-statement/m-p/524286#M147909</link>
      <description>&lt;P&gt;Thanks for the concise example of if expression.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 23:05:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-using-IF-statement/m-p/524286#M147909</guid>
      <dc:creator>yshen</dc:creator>
      <dc:date>2020-10-12T23:05:55Z</dc:date>
    </item>
    <item>
      <title>Re: Search using IF statement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-using-IF-statement/m-p/709035#M239673</link>
      <description>&lt;P&gt;I have a question&lt;/P&gt;&lt;P&gt;I Did this on an event and basically did the If command - that if above 15 mins then Output is BAD and if under 15 the. output is GOOD - This works.&lt;/P&gt;&lt;P&gt;My question is I now want to search only the BAD and alert - so guess how do I start another search after I have run eval and got my BAD output?&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2025 00:26:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-using-IF-statement/m-p/709035#M239673</guid>
      <dc:creator>LizAndy123</dc:creator>
      <dc:date>2025-01-17T00:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: Search using IF statement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-using-IF-statement/m-p/709037#M239674</link>
      <description>&lt;P&gt;FWIW, it's usually better to ask a new question than to pile on to a 4-year-old thread.&lt;/P&gt;&lt;P&gt;To keep only the BAD events, try one of these&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=my_index
| eval my_check=if(my_field&amp;gt;100,"NOK","OK")
| where my_check="NOK"
| table _time my_check&lt;/LI-CODE&gt;&lt;P&gt;or&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=my_index
| where my_field&amp;gt;100
| table _time my_field&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2025 01:16:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-using-IF-statement/m-p/709037#M239674</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2025-01-17T01:16:51Z</dc:date>
    </item>
  </channel>
</rss>

