<?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 Comparison and condition function help. Multiple If, case or like statements in search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Comparison-and-condition-function-help-Multiple-If-case-or-like/m-p/441388#M125391</link>
    <description>&lt;PRE&gt;&lt;CODE&gt;index=foo
| eval Compliant=case(like(AppVersion,"14.12%"), "OK", like(AppVersion,"14.11%"),"OK" , like(AppVersion,"14.10%"),"OK" , like(AppVersion,"14.9%"),"OK" , like(AppVersion,"14.8%"),"OK"...)
| table User, Platform, AppVersion, Compliant
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Right now table looks like this. I have only checked if an AppVersion is on the Compliant list. &lt;BR /&gt;
12345| Windows  | 14.8       | Ok&lt;BR /&gt;
56789| Mac           | 12.8       | &lt;BR /&gt;
03468| iOS       | 18.0       |&lt;BR /&gt;
97621| Android    | 18.8       | &lt;/P&gt;

&lt;P&gt;However, I need to check certain AppVersions against the Platform. &lt;BR /&gt;
I imagine it would need multiple if statements and multiple cases but not sure how to do this.&lt;BR /&gt;
One of my failures looked something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo
| eval Compliant=if(Platform=Windows, case(like(AppVersion,"14.12%"), "OK", like(AppVersion,"14.11%"),"OK" , like(AppVersion,"14.10%"),"OK" , like(AppVersion,"14.9%"),"OK" , like(AppVersion,"14.8%"),"OK"...),"NO")
| table foo
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The goal would be to show something like this.&lt;BR /&gt;
User | Platform | AppVersion | Compliant&lt;BR /&gt;
12345| Windows  | 14.8       | Ok&lt;BR /&gt;
56789| Mac           | 12.8       | Ok&lt;BR /&gt;
03468| iOS      | 18.0       | Ok&lt;BR /&gt;
97621| Android    | 18.8       | Ok&lt;BR /&gt;
97423| Windows  | 13.8       | No&lt;BR /&gt;
32638| Mac          | 11.0       | No&lt;BR /&gt;
08346| iOS      | 17.0       | No&lt;BR /&gt;
43835| Android   | 18.2       | No&lt;/P&gt;

&lt;P&gt;Thank you in advance, if you can help. &lt;/P&gt;</description>
    <pubDate>Fri, 31 Aug 2018 21:22:00 GMT</pubDate>
    <dc:creator>nqjpm</dc:creator>
    <dc:date>2018-08-31T21:22:00Z</dc:date>
    <item>
      <title>Comparison and condition function help. Multiple If, case or like statements in search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparison-and-condition-function-help-Multiple-If-case-or-like/m-p/441388#M125391</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;index=foo
| eval Compliant=case(like(AppVersion,"14.12%"), "OK", like(AppVersion,"14.11%"),"OK" , like(AppVersion,"14.10%"),"OK" , like(AppVersion,"14.9%"),"OK" , like(AppVersion,"14.8%"),"OK"...)
| table User, Platform, AppVersion, Compliant
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Right now table looks like this. I have only checked if an AppVersion is on the Compliant list. &lt;BR /&gt;
12345| Windows  | 14.8       | Ok&lt;BR /&gt;
56789| Mac           | 12.8       | &lt;BR /&gt;
03468| iOS       | 18.0       |&lt;BR /&gt;
97621| Android    | 18.8       | &lt;/P&gt;

&lt;P&gt;However, I need to check certain AppVersions against the Platform. &lt;BR /&gt;
I imagine it would need multiple if statements and multiple cases but not sure how to do this.&lt;BR /&gt;
One of my failures looked something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo
| eval Compliant=if(Platform=Windows, case(like(AppVersion,"14.12%"), "OK", like(AppVersion,"14.11%"),"OK" , like(AppVersion,"14.10%"),"OK" , like(AppVersion,"14.9%"),"OK" , like(AppVersion,"14.8%"),"OK"...),"NO")
| table foo
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The goal would be to show something like this.&lt;BR /&gt;
User | Platform | AppVersion | Compliant&lt;BR /&gt;
12345| Windows  | 14.8       | Ok&lt;BR /&gt;
56789| Mac           | 12.8       | Ok&lt;BR /&gt;
03468| iOS      | 18.0       | Ok&lt;BR /&gt;
97621| Android    | 18.8       | Ok&lt;BR /&gt;
97423| Windows  | 13.8       | No&lt;BR /&gt;
32638| Mac          | 11.0       | No&lt;BR /&gt;
08346| iOS      | 17.0       | No&lt;BR /&gt;
43835| Android   | 18.2       | No&lt;/P&gt;

&lt;P&gt;Thank you in advance, if you can help. &lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 21:22:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparison-and-condition-function-help-Multiple-If-case-or-like/m-p/441388#M125391</guid>
      <dc:creator>nqjpm</dc:creator>
      <dc:date>2018-08-31T21:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: Comparison and condition function help. Multiple If, case or like statements in search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparison-and-condition-function-help-Multiple-If-case-or-like/m-p/441389#M125392</link>
      <description>&lt;P&gt;I think a lookup should be used here!! Can you try on that lines, if you already know the conditions for Compliant? That way you can use a csv file for the true conditions of Compliant . &lt;BR /&gt;
Your lookup should have User Platform AppVersion columns.&lt;/P&gt;

&lt;P&gt;basequery|lookup Compliant_condtions.csv User AS User, Platform  AS Platform , columns AS columns OUTPUT Compliant&lt;BR /&gt;
|fillnull value="No" Compliant  ------ &amp;gt; this will fill the Complaint values as "No" for the condition that dint match with the lookup&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 22:13:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparison-and-condition-function-help-Multiple-If-case-or-like/m-p/441389#M125392</guid>
      <dc:creator>nadlurinadluri</dc:creator>
      <dc:date>2018-08-31T22:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: Comparison and condition function help. Multiple If, case or like statements in search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparison-and-condition-function-help-Multiple-If-case-or-like/m-p/441390#M125393</link>
      <description>&lt;P&gt;@nqjpm,&lt;/P&gt;

&lt;P&gt;Try below query..&lt;BR /&gt;
I have created with sample data . You can us the last eval with your main query.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    | makeresults
 | eval AppVersion=mvappend("14.12%","14.11%","14.10%","14.16%","14.00%")
 | mvexpand AppVersion          
 | eval Platform= case(AppVersion == "14.00%", "Windows",AppVersion == "14.12%", "Windows",AppVersion == "14.16%","Mac",AppVersion == "14.12%", "iOS",AppVersion == "14.11%", "Windows",AppVersion == "14.11%", "Mac",AppVersion == "14.10%", "Windows",AppVersion == "14.10%", "Android")
 | eval Compliant=if(Platform="Windows" AND (AppVersion="14.12%" OR AppVersion="14.11%" OR AppVersion="14.10%" OR AppVersion="14.9%" OR AppVersion="14.8%"), "OK","NO" )
 | table   AppVersion Platform Compliant
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks ..&lt;/P&gt;</description>
      <pubDate>Sat, 01 Sep 2018 05:22:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparison-and-condition-function-help-Multiple-If-case-or-like/m-p/441390#M125393</guid>
      <dc:creator>Shan</dc:creator>
      <dc:date>2018-09-01T05:22:49Z</dc:date>
    </item>
  </channel>
</rss>

