<?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: How to perform nested if conditions in Splunk in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-perform-nested-if-conditions-in-Splunk/m-p/108047#M183425</link>
    <description>&lt;P&gt;I am not able to post it in the comments for some reason. So, I updated the post. I have also added the sample output.&lt;/P&gt;</description>
    <pubDate>Sat, 27 Jul 2013 13:51:30 GMT</pubDate>
    <dc:creator>naveenurs</dc:creator>
    <dc:date>2013-07-27T13:51:30Z</dc:date>
    <item>
      <title>How to perform nested if conditions in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-perform-nested-if-conditions-in-Splunk/m-p/108039#M183417</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Example 1:&lt;/STRONG&gt;  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;uatoken0=Linux
uatoken1=U
uatoken2=Android
uatoken3=en-us
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Example 2:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;uatoken0=Linux
uatoken1=Android 4.2.2
uatoken2=en-us
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Example 3:&lt;/STRONG&gt;&lt;BR /&gt;
uatoken0=iPad&lt;BR /&gt;
uatoken1=CPU OS 6_1_3 like Mac OS X&lt;BR /&gt;
uatoken2=&lt;/P&gt;

&lt;P&gt;I want to achieve the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;**if** (uatoken0="Linux" **AND** **if** uatoken1="U")==**TRUE** 
**then** OS=uatoken2
**else if**(uatoken0="Linux" **AND** **if** uatoken1="Android 4.2.2"
**then** OS=uatoken1
**else** OS=uatoken0;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is what I have accomplished so far:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|eval uatokentmp=split(uatoken,";")
|eval uatoken0=mvindex(uatokentmp,0)
|eval uatoken1=mvindex(uatokentmp,1)
|eval uatoken2=mvindex(uatokentmp,2)
|eval uatoken3=mvindex(uatokentmp,3)
|eval uatoken4=mvindex(uatokentmp,4)
| eval uatoken5=mvindex(uatokentmp,5)
|eval OS=if(mvindex(uatokentmp,0)="Linux",
    (if(mvindex(uatokentmp,1)="U",
                mvindex(uatokentmp,2),
                mvindex(uatokentmp,1))),
    mvindex(uatokentmp,0)) 
| table OS uatoken0 uatoken1 uatoken2 uatoken3 uatoken4 uatoken5
|sort OS
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This works for &lt;STRONG&gt;Example 2&lt;/STRONG&gt; and &lt;STRONG&gt;Example 3&lt;/STRONG&gt;. However, it fails for &lt;STRONG&gt;Example 1&lt;/STRONG&gt;. The output for &lt;STRONG&gt;Example 1&lt;/STRONG&gt; is OS="U".&lt;/P&gt;

&lt;P&gt;I am not able to figure out what is wrong. Need another set of eyes to go through my code and help me.&lt;BR /&gt;
If there is a better way to do this, please advise.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;This is the original query that I was trying to run when I posted the question:&lt;BR /&gt;
eventtype=video|eval uatokentmp=split(uatoken,";")&lt;BR /&gt;
|eval uatoken0=mvindex(uatokentmp,0)&lt;BR /&gt;
|eval uatoken1=mvindex(uatokentmp,1)&lt;BR /&gt;
|eval uatoken2=mvindex(uatokentmp,2)&lt;BR /&gt;
|eval uatoken3=mvindex(uatokentmp,3)&lt;BR /&gt;
|eval uatoken4=mvindex(uatokentmp,4)&lt;BR /&gt;
| eval uatoken5=mvindex(uatokentmp,5)&lt;BR /&gt;
|eval OS=if(mvindex(uatokentmp,0)="Linux",&lt;BR /&gt;
    (if(mvindex(uatokentmp,1)="U",&lt;BR /&gt;
                mvindex(uatokentmp,2),&lt;BR /&gt;
                mvindex(uatokentmp,1))),&lt;BR /&gt;
    mvindex(uatokentmp,0)) &lt;BR /&gt;
| table OS uatoken0 uatoken1 uatoken2 uatoken3 uatoken4 uatoken5&lt;BR /&gt;
|sort OS&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Sample uatoken output&lt;/STRONG&gt;&lt;BR /&gt;
iPad; CPU OS 6_1_3 like Mac OS X&lt;BR /&gt;
Windows NT 6.2; WOW64&lt;BR /&gt;
compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0&lt;BR /&gt;
compatible; MSIE 7.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E&lt;BR /&gt;
Linux; Android 4.3; Nexus 7 Build/JWR66V&lt;BR /&gt;
Windows NT 5.1&lt;BR /&gt;
Windows NT 6.1; WOW64&lt;BR /&gt;
Macintosh; Intel Mac OS X 10_8_4&lt;BR /&gt;
Macintosh; Intel Mac OS X 10.8; rv:22.0&lt;BR /&gt;
Windows NT 6.1; WOW64; rv:22.0&lt;BR /&gt;
Macintosh; Intel Mac OS X 10_6_8&lt;BR /&gt;
Windows NT 6.0; rv:22.0&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0; MDDCJS&lt;BR /&gt;
iPhone; CPU iPhone OS 6_1_4 like Mac OS X&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0&lt;BR /&gt;
iPhone; CPU iPhone OS 6_1_3 like Mac OS X&lt;BR /&gt;
Macintosh; Intel Mac OS X 10.6; rv:22.0&lt;BR /&gt;
Windows NT 5.1; rv:22.0&lt;BR /&gt;
Linux; U; Android 2.3.4; en-us; SCH-R720 Build/GINGERBREAD&lt;BR /&gt;
Linux; U; Android 2.3.6; en-us; X501_USA_Cricket Build/GRK39F&lt;BR /&gt;
Linux; U; Android 4.2.2; en-us; SAMSUNG-SGH-I537 Build/JDQ39&lt;BR /&gt;
Windows NT 6.1; WOW64; rv:6.0.2&lt;BR /&gt;
Macintosh; Intel Mac OS X 10_5_8&lt;BR /&gt;
Windows NT 6.1; rv:22.0&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.2; Win64; x64; Trident/6.0; MDDCJS&lt;BR /&gt;
compatible; Googlebot/2.1; +&lt;A href="http://www.google.com/bot.html" target="_blank"&gt;http://www.google.com/bot.html&lt;/A&gt;&lt;BR /&gt;
Windows NT 6.1&lt;BR /&gt;
Linux; U; Android 4.1.1; en-us; SAMSUNG-SGH-I747 Build/JRO03L&lt;BR /&gt;
Linux; U; Android 2.2.1; en-us; VM670 Build/FRG83&lt;BR /&gt;
compatible; MSIE 7.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30618; yie8&lt;BR /&gt;
iPad; CPU OS 6_0_1 like Mac OS X&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET CLR 1.1.4322&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB7.5; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C&lt;BR /&gt;
Linux; U; Android 4.1.2; en-us; GT-N8013 Build/JZO54K&lt;BR /&gt;
Windows NT 6.0&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.2; Win64; x64; Trident/6.0; Touch; MALNJS&lt;BR /&gt;
Macintosh; Intel Mac OS X 10_7_5&lt;BR /&gt;
Macintosh; Intel Mac OS X 10.7; rv:22.0&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB7.5; .NET CLR 1.1.4322; MSN Optimized;CA; .NET4.0C; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; BOIE8;ENUS&lt;BR /&gt;
Linux; U; Android 2.3.7; en-us; 5860e Build/GWK74&lt;BR /&gt;
X11; Ubuntu; Linux x86_64; rv:22.0&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0&lt;BR /&gt;
Linux; U; Android 4.1.2; en-us; SPH-L710 Build/JZO54K&lt;BR /&gt;
Linux; U; Android 2.3.4; en-us; ADR6350 Build/GRJ22&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0; BOIE9;ENUS&lt;BR /&gt;
compatible; MSIE 9.0; Windows NT 6.0; Trident/5.0&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; InfoPath.3&lt;BR /&gt;
compatible; MSIE 9.0; Windows NT 6.0; WOW64; Trident/5.0&lt;BR /&gt;
iPad; CPU OS 6_1_2 like Mac OS X&lt;BR /&gt;
Windows NT 6.2&lt;BR /&gt;
X11; Ubuntu; Linux i686; rv:19.0&lt;BR /&gt;
Macintosh; Intel Mac OS X 10_8_2&lt;BR /&gt;
compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0&lt;BR /&gt;
Windows NT 6.1; rv:23.0&lt;BR /&gt;
iPad; CPU OS 5_1_1 like Mac OS X&lt;BR /&gt;
Android; Mobile; rv:21.0&lt;BR /&gt;
Linux; U; Android 4.1.2; en-us; SCH-I535 Build/JZO54K&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 6.1; Win64; x64; Trident/4.0; GTB7.5; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; HPDTDF; Tablet PC 2.0; .NET4.0C; InfoPath.3&lt;BR /&gt;
Linux; U; Android 4.1.2; en-us; DROID RAZR Build/9.8.2O-72_VZW-16&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0; NP06&lt;BR /&gt;
Linux; U; Android 2.3.5; en-us; SCH-I500 Build/GINGERBREAD&lt;BR /&gt;
iPad; CPU OS 6_1 like Mac OS X&lt;BR /&gt;
compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; USPortal&lt;BR /&gt;
Linux; Android 4.0.3; GT-I9100T Build/IML74K&lt;BR /&gt;
Linux; U; Android 4.1.2; en-us; HTC_PN07120/1.26.502.12 Build/JZO54K&lt;BR /&gt;
iPhone; CPU iPhone OS 6_0 like Mac OS X&lt;BR /&gt;
Linux; U; Android 4.0.4; en-us; KFJWI Build/IMM76D&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0; EIE10;ENUSMCM&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB7.5; BRI/2; AskTbORJ/5.15.25.36191; BOIE8;ENUS&lt;BR /&gt;
iPad; CPU OS 6_0 like Mac OS X&lt;BR /&gt;
Linux; U; en-us; KFOT Build/IML74K&lt;BR /&gt;
compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322&lt;BR /&gt;
Linux; Android 4.2.2; SAMSUNG-SGH-I337 Build/JDQ39&lt;BR /&gt;
Windows NT 6.1; rv:9.0.1&lt;BR /&gt;
X11; Linux x86_64&lt;BR /&gt;
Linux; Android 4.2.2; en-au; SAMSUNG GT-I9505 Build/JDQ39&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0; EIE10;ENUSMSN&lt;BR /&gt;
Linux; U; Android 2.3.4; en-us; Sprint APA7373KT Build/GRJ22&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322; MS-RTC LM 8; .NET4.0C; BOIE8;ENUSMSCOM; .NET4.0E; BOIE8;ENUSMSCOM&lt;BR /&gt;
Linux; U; Android 4.0.4; en-us; SGH-T989 Build/IMM76D&lt;BR /&gt;
Linux; U; Android 2.3.4; en-us; NOOK BNTV250 Build/GINGERBREAD 1.4.3&lt;BR /&gt;
Linux; U; Android 2.3.5; en-us; PantechP9070 Build/GRJ90&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0; MALNJS&lt;BR /&gt;
compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; HTC; HTC6990LVW&lt;BR /&gt;
Linux; U; Android 2.3.4; en-us; Silk/1.0.22.153_10033210&lt;BR /&gt;
Linux; U; Android 2.3.3; en-us; DROIDX Build/4.5.1_57_DX5-35&lt;BR /&gt;
Linux; U; en-us; KFTT Build/IML74K&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0; MDDRJS&lt;BR /&gt;
iPhone; CPU iPhone OS 5_1_1 like Mac OS X&lt;BR /&gt;
Linux; U; Android 2.3.6; en-us; SAMSUNG-SGH-I727 Build/GINGERBREAD&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C&lt;BR /&gt;
Linux; U; Android 4.1.2; en-us; SCH-R530U Build/JZO54K&lt;BR /&gt;
compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0&lt;BR /&gt;
Windows NT 6.2; WOW64; rv:22.0&lt;BR /&gt;
PlayBook; U; RIM Tablet OS 2.1.0; en-US&lt;BR /&gt;
compatible; MSIE 7.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E&lt;BR /&gt;
Linux; U; Android 2.3.4; en-us; MB855 Build/4.5.1A-1_SUN-154_MR-1&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET4.0C&lt;BR /&gt;
X11; Linux i686; rv:22.0&lt;BR /&gt;
Linux; U; Android 4.0.4; en-us; SPH-D710 Build/IMM76I&lt;BR /&gt;
Macintosh; Intel Mac OS X 10_8_3&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E&lt;BR /&gt;
Linux; U; Android 4.1.2; en-us; SCH-I605 Build/JZO54K&lt;BR /&gt;
compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; GTB7.5; chromeframe/29.0.1547.32; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C&lt;BR /&gt;
iPhone; U; CPU iPhone OS 4_2_6 like Mac OS X; en-us&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0; MALC&lt;BR /&gt;
iPad; U; CPU OS 4_3_4 like Mac OS X; en-us&lt;BR /&gt;
iPad; U; CPU OS 4_3_5 like Mac OS X; en-us&lt;BR /&gt;
Linux; U; Android 4.1.2; en-gb; SAMSUNG GT-I9300/I9300XXEMC2 Build/JZO54K&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; MS-RTC LM 8&lt;BR /&gt;
Windows NT 6.1; rv:19.0&lt;BR /&gt;
Linux; Android 4.1.2; DROID RAZR Build/9.8.2O-72_VZW-16&lt;BR /&gt;
Linux; U; Android 4.1.2; en-us; DROID BIONIC Build/9.8.2O-72_VZW-22&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0; Touch; MDDCJS&lt;BR /&gt;
Macintosh; Intel Mac OS X 10_7_4&lt;BR /&gt;
Linux; U; Android 2.3.6; en-us; SPH-M820-BST Build/GINGERBREAD&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB7.5; .NET CLR 1.0.3705; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152&lt;BR /&gt;
Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.0.22.153_10033210&lt;BR /&gt;
iPhone; CPU iPhone OS 6_0_1 like Mac OS X&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; GTB7.5; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; InfoPath.2; .NET CLR 3.5.30729; .NET4.0C; .NET CLR 3.0.30729&lt;BR /&gt;
Linux; U; Android 4.0.3; en-us; KFTT Build/IML74K&lt;BR /&gt;
X11; Linux x86_64; rv:20.0&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; MS-RTC LM 8; .NET4.0E; CH2M&lt;BR /&gt;
Macintosh; Intel Mac OS X 10.8; rv:15.0&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MS-RTC LM 8; .NET4.0C; .NET4.0E; InfoPath.3&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0; Media Center PC 3.0; McAfee; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.2; Win64; x64; Trident/6.0; MATBJS&lt;BR /&gt;
compatible; MSIE 6.0; Windows NT 5.1; SV1; BTRS101477; .NET CLR 2.0.50727&lt;BR /&gt;
compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322; InfoPath.1; BRI/2; OfficeLiveConnector.1.5; OfficeLivePatch.1.3&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0; MAAU&lt;BR /&gt;
compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920&lt;BR /&gt;
iPhone; CPU iPhone OS 6_1 like Mac OS X&lt;BR /&gt;
compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/6.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MAAU; .NET4.0C; OfficeLiveConnector.1.5; OfficeLivePatch.1.3; BRI/2; NET_mmhpset; IE0006_ver1;EN_US&lt;BR /&gt;
Linux; U; Android 4.0.4; en-us; C5170 Build/IML77&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB7.5; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; MDDC; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C&lt;BR /&gt;
Windows NT 6.1; rv:20.0&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E&lt;BR /&gt;
Linux; U; Android 4.1.2; en-us; N861 Build/JZO54K&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.2; .NET4.0E; MS-RTC LM 8; Tablet PC 2.0&lt;BR /&gt;
X11; Ubuntu; Linux i686; rv:22.0&lt;BR /&gt;
iPod; CPU iPhone OS 6_1_3 like Mac OS X&lt;BR /&gt;
Windows NT 5.1; rv:20.0&lt;BR /&gt;
iPhone; CPU iPhone OS 6_1_2 like Mac OS X&lt;BR /&gt;
Linux; U; Android 2.3.6; en-gb; GT-I9000 Build/GINGERBREAD&lt;BR /&gt;
X11; Linux i686&lt;BR /&gt;
compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; MDDCJS&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.1; Win64; x64; Trident/6.0&lt;BR /&gt;
Linux; U; Android 4.1.1; en-us; EVO Build/JRO03C&lt;BR /&gt;
iPad; U; CPU OS 4_3_1 like Mac OS X; en-us&lt;BR /&gt;
Linux; U; Android 2.3.6; en-us; M865 Build/HuaweiM865&lt;BR /&gt;
Linux; U; Android 4.1.1; en-us; GT-P5113 Build/JRO03C&lt;BR /&gt;
Linux; U; Android 4.0.4; en-us; SPH-D710VMUB Build/IMM76I&lt;BR /&gt;
Windows NT 6.1; WOW64; rv:19.0&lt;BR /&gt;
Linux; U; Android 2.3.3; en-us; SC-02C Build/GINGERBREAD&lt;BR /&gt;
Linux; Android 4.0.4; SAMSUNG-SGH-I717 Build/IMM76D&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0; ASU2JS&lt;BR /&gt;
Macintosh; Intel Mac OS X 10.5; rv:16.0&lt;BR /&gt;
Linux; U; Android 4.0.4; en-gb; SonyEricssonLT26i Build/6.1.A.2.45&lt;BR /&gt;
compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; GTB7.5; BTRS100194; .NET CLR 1.1.4322; WinNT-PAI 28.08.2009; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729&lt;BR /&gt;
Linux; U; Android 4.0.4; en-us; A210 Build/IMM76D&lt;BR /&gt;
Linux; Android 4.0.4; SPH-D710 Build/IMM76I&lt;BR /&gt;
Linux; U; Android 2.3.5; en-us; Sprint APA9292KT Build/GRJ90&lt;BR /&gt;
Linux; U; Android 4.0.4; en-us; EVO Build/IMM76D&lt;BR /&gt;
Linux; U; Android 4.0.4; en-us; C5155 Build/IML77&lt;BR /&gt;
Linux; U; Android 4.1.2; en-au; GT-I9300 Build/JZO54K&lt;BR /&gt;
iPad; CPU OS 5_1 like Mac OS X&lt;BR /&gt;
BlackBerry; U; BlackBerry 9900; en-US&lt;BR /&gt;
Linux; Android 4.2.2; Nexus 7 Build/JDQ39&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; GTB6; FunWebProducts; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET4.0C; BRI/1; BRI/2; .NET CLR 3.0.30729; FunWebProducts&lt;BR /&gt;
Linux; Android 4.2.2; Nexus 4 Build/JDQ39&lt;BR /&gt;
Macintosh; Intel Mac OS X 10.8; rv:23.0&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MALC; .NET4.0C; InfoPath.2; MS-RTC LM 8&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0; msn OptimizedIE8;ENUS&lt;BR /&gt;
Linux; Android 4.1.2; XT907 Build/9.8.1Q-78&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; GTB7.5; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; AskTbORJ/5.14.1.20007&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0; FunWebProducts&lt;BR /&gt;
Linux; U; Android 2.3.6; en-us; SCH-I510 4G Build/FP8&lt;BR /&gt;
Linux; U; Android 4.0.3; en-us; HTC_PH39100/3.26.502.56 Build/IML74K&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; GTB7.5; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MDDC; .NET4.0C&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0; MSN 9.0;MSN 9.1;MSN 9.6;MSN 10.0;MSN 10.2;MSN 10.5; MSNbMSNI; MSNmen-us; MSNcOTH&lt;BR /&gt;
Linux; U; Android 4.1.1; en-us; HTC6435LVW 4G Build/JRO03C&lt;BR /&gt;
compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 1.0.3705; InfoPath.2; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET4.0C&lt;BR /&gt;
X11; CrOS armv7l 4100.68.0&lt;BR /&gt;
Linux; Android 4.1.1; GT-P3113 Build/JRO03C&lt;BR /&gt;
X11; Ubuntu; Linux i686; rv:11.0&lt;BR /&gt;
Windows NT 6.0; WOW64; rv:22.0&lt;BR /&gt;
X11; CrOS i686 4100.68.0&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0; ARM; Touch; WPDesktop&lt;BR /&gt;
iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; en-us&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0; MAM3&lt;BR /&gt;
iPod; CPU iPhone OS 6_0 like Mac OS X&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; GIL 3; SLCC1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; InfoPath.2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; GIL3&lt;BR /&gt;
Linux; U; Android 2.3.5; en-us; DROID X2 Build/4.5.1A-DTN-200-18&lt;BR /&gt;
compatible; MSIE 10.0; AOL 9.7; AOLBuild 4343.1028; Windows NT 6.1; WOW64; Trident/6.0; MALC&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; InfoPath.2; .NET4.0C; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729&lt;BR /&gt;
iPod; CPU iPhone OS 5_1_1 like Mac OS X&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SearchToolbar 1.2; BTRS103198; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0; .NET CLR 2.0.50727; Qwest 1.0; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; McAfee&lt;BR /&gt;
iPod; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us&lt;BR /&gt;
Linux; Android 4.2.2; Matricom G-Box Midnight MX2 Build/JDQ39&lt;BR /&gt;
Linux; Android 4.2.2; en-us; SAMSUNG-SGH-I337 Build/JDQ39&lt;BR /&gt;
compatible; MSIE 7.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; Tablet PC 2.0; .NET4.0C; .NET4.0E&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET CLR 1.1.4322&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB7.5; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0&lt;BR /&gt;
iPod; CPU iPhone OS 5_1 like Mac OS X&lt;BR /&gt;
Linux; Android 4.2.2; en-us; SAMSUNG SCH-I545 Build/JDQ39&lt;BR /&gt;
Windows NT 5.1; rv:17.0&lt;BR /&gt;
iPad; U; CPU OS 4_3_2 like Mac OS X; en-us&lt;BR /&gt;
Linux; U; Android 4.1.2; en-gb; GT-I9300 Build/JZO54K&lt;BR /&gt;
Android; Mobile; rv:22.0&lt;BR /&gt;
Linux; U; Android 4.2.2; en-us; HTC One Build/JDQ39&lt;BR /&gt;
Linux; Android 4.2.2; SCH-I545 Build/JDQ39&lt;BR /&gt;
compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; Avant Browser&lt;BR /&gt;
Linux; U; Android 4.1.2; en-us; SGH-T889 Build/JZO54K&lt;BR /&gt;
BlackBerry; U; BlackBerry 9670; en-US&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; BTRS125127; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322; .NET4.0C&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.2; Win64; x64; Trident/6.0; Touch; MDDCJS&lt;BR /&gt;
Linux; Android 4.0.4; BNTV400 Build/IMM76L&lt;BR /&gt;
Linux; U; Android 2.3.5; en-us; Desire HD Build/GRJ90&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB7.5; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; Tablet PC 2.0&lt;BR /&gt;
compatible; MSIE 9.0; Windows NT 6.0; WOW64; Trident/5.0; msn OptimizedIE8;ENUS&lt;BR /&gt;
iPhone; U; CPU iPhone OS 4_1 like Mac OS X; en-us&lt;BR /&gt;
iPhone; CPU iPhone OS 5_1 like Mac OS X&lt;BR /&gt;
Linux; Android 4.0.4; SHV-E160S Build/IMM76D&lt;BR /&gt;
Windows NT 6.0; WOW64&lt;BR /&gt;
Macintosh; U; Intel Mac OS X 10_4_11; en&lt;BR /&gt;
BB10; Kbd&lt;BR /&gt;
Linux; U; Android 2.3.6; en-us; DROID RAZR 4G Build/6.5.1-167_DHD-14_M3-8&lt;BR /&gt;
compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0; MATBJS&lt;BR /&gt;
Linux; U; Android 4.1.2; en-us; SGH-T999 Build/JZO54K&lt;BR /&gt;
compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MS-RTC LM 8; .NET4.0C; .NET4.0E&lt;BR /&gt;
Linux; U; Android 2.2; en-us; Sprint APA9292KT Build/FRF91&lt;BR /&gt;
Linux; Android 4.1.2; XT901 Build/9.8.2Q-50_SLS-13&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:26:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-perform-nested-if-conditions-in-Splunk/m-p/108039#M183417</guid>
      <dc:creator>naveenurs</dc:creator>
      <dc:date>2020-09-28T14:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform nested if conditions in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-perform-nested-if-conditions-in-Splunk/m-p/108040#M183418</link>
      <description>&lt;P&gt;This should do it..&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval OS = case(uatoken0=="Linux" AND uatoken1=="U", uatoken2,
                 uatoken0=="Linux" AND uatoken1=="Android 4.2.2", uatoken1,
                 1==1, uatoken0)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And as @Ayn mentions above, you can use the  &lt;CODE&gt;match()&lt;/CODE&gt; function as well...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval OS = case(match(uatoken0,"(?i)Linux") AND uatoken1=="U", uatoken2,
                 match(uatoken0,"(?i)Linux") AND match(uatoken1,"(?i)Android"), uatoken1,
                 1==1, uatoken0)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note that my regexes above are set to be case-insensitive. The matches are simply looking for that string at any position within the variable's text.&lt;/P&gt;

&lt;P&gt;Note that the &lt;CODE&gt;case&lt;/CODE&gt; function conditions are evaluated in order; the first condition that evaluates to &lt;CODE&gt;true&lt;/CODE&gt; is accepted and the remainder are ignored. So order of the clauses is important.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2013 18:20:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-perform-nested-if-conditions-in-Splunk/m-p/108040#M183418</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-07-26T18:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform nested if conditions in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-perform-nested-if-conditions-in-Splunk/m-p/108041#M183419</link>
      <description>&lt;P&gt;Thanks for responding.&lt;/P&gt;

&lt;P&gt;Using case has a problem. I will not be able to use wildcard character for Android to select all android versions. Essentially, my query should be if uatoken1=="Android*"&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2013 19:02:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-perform-nested-if-conditions-in-Splunk/m-p/108041#M183419</guid>
      <dc:creator>naveenurs</dc:creator>
      <dc:date>2013-07-26T19:02:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform nested if conditions in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-perform-nested-if-conditions-in-Splunk/m-p/108042#M183420</link>
      <description>&lt;P&gt;That's not a problem with case itself, that's something that depends on what you feed case with. In your case, you'll want to use match which performs regular expression matching against whatever field you want to use.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;case(match(uatoken1,"^Android") ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;As a sidenote, if you're going into user agent parsing territory, godspeed. You might want to consider using the excellent user agent parser app that's available on splunkbase: &lt;A href="http://splunk-base.splunk.com/apps/48017/ta-uas_parser"&gt;http://splunk-base.splunk.com/apps/48017/ta-uas_parser&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2013 19:34:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-perform-nested-if-conditions-in-Splunk/m-p/108042#M183420</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-07-26T19:34:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform nested if conditions in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-perform-nested-if-conditions-in-Splunk/m-p/108043#M183421</link>
      <description>&lt;P&gt;I second @Ayn's suggestion of the user agent parser.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2013 20:07:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-perform-nested-if-conditions-in-Splunk/m-p/108043#M183421</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-07-26T20:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform nested if conditions in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-perform-nested-if-conditions-in-Splunk/m-p/108044#M183422</link>
      <description>&lt;P&gt;Thanks to both of you! Appreciate your help.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2013 20:44:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-perform-nested-if-conditions-in-Splunk/m-p/108044#M183422</guid>
      <dc:creator>naveenurs</dc:creator>
      <dc:date>2013-07-26T20:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform nested if conditions in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-perform-nested-if-conditions-in-Splunk/m-p/108045#M183423</link>
      <description>&lt;P&gt;match has not helped.&lt;/P&gt;

&lt;P&gt;OS       uatoken0   uatoken1       uatoken2 uatoken3    uatoken4                                                   uatoken5&lt;BR /&gt;
Linux   Linux    U           Android 2.2.1   en-us   SAMSUNG-SGH-I997 Build/FROYO   &lt;/P&gt;

&lt;P&gt;As you can see, OS is still showing as Linux and not Android.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2013 20:53:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-perform-nested-if-conditions-in-Splunk/m-p/108045#M183423</guid>
      <dc:creator>naveenurs</dc:creator>
      <dc:date>2013-07-26T20:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform nested if conditions in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-perform-nested-if-conditions-in-Splunk/m-p/108046#M183424</link>
      <description>&lt;P&gt;Can you post the exact search string that you are now using? Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2013 21:52:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-perform-nested-if-conditions-in-Splunk/m-p/108046#M183424</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-07-26T21:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform nested if conditions in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-perform-nested-if-conditions-in-Splunk/m-p/108047#M183425</link>
      <description>&lt;P&gt;I am not able to post it in the comments for some reason. So, I updated the post. I have also added the sample output.&lt;/P&gt;</description>
      <pubDate>Sat, 27 Jul 2013 13:51:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-perform-nested-if-conditions-in-Splunk/m-p/108047#M183425</guid>
      <dc:creator>naveenurs</dc:creator>
      <dc:date>2013-07-27T13:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform nested if conditions in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-perform-nested-if-conditions-in-Splunk/m-p/108048#M183426</link>
      <description>&lt;P&gt;Uh, I don't see you using the suggested solutions at all in your search?&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2013 18:15:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-perform-nested-if-conditions-in-Splunk/m-p/108048#M183426</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-07-30T18:15:54Z</dc:date>
    </item>
  </channel>
</rss>

