<?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 lookup with catch-all value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/conditional-lookup-with-catch-all-value/m-p/410619#M167218</link>
    <description>&lt;P&gt;Hi @thezen,&lt;/P&gt;

&lt;P&gt;Try below query&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourBaseSearch&amp;gt;
| lookup yourlookup.csv raw_field1 AS FIELD1, raw_field2 AS FIELD2 OUTPUT MATCHTAG AS MATCHTAG, UNMATCHEDTAG AS UNMATCHEDTAG 
| eval merged_tag = coalesce(MATCHTAG, UNMATCHEDTAG)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 08 Oct 2018 10:01:53 GMT</pubDate>
    <dc:creator>harsmarvania57</dc:creator>
    <dc:date>2018-10-08T10:01:53Z</dc:date>
    <item>
      <title>conditional lookup with catch-all value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/conditional-lookup-with-catch-all-value/m-p/410618#M167217</link>
      <description>&lt;P&gt;I am looking to retrieve the following a field from a lookup table depending on the lookup result of two fields as follow,&lt;/P&gt;

&lt;P&gt;Current lookup table sample:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;FIELD1  FIELD2  MATCHTAG    UNMATCHEDTAG
A       123     string1 string2
B       456     string3 string4
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;All of the events will always have a matching value for field1, but not on field2. Those event which has a matching for both field1 and field2 will have to append the corresponding MATCHTAG field value (string1), otherwise (if it doesn't have matching value for FIELD2) it will have to append "string2" instead to the result set (which will also contain the matching events).&lt;/P&gt;

&lt;P&gt;Event Sample,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;A 123 
A 789
B 789
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Ideal Result,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;A 123 string1
A 789 string2
B 789 string4
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I know we can do a lookup and return the non-matching result set, but not so sure on how I can append the UNMATCHEDTAG to the result set together. &lt;/P&gt;

&lt;P&gt;Appreciate any suggestions on this,&lt;/P&gt;</description>
      <pubDate>Mon, 08 Oct 2018 00:07:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/conditional-lookup-with-catch-all-value/m-p/410618#M167217</guid>
      <dc:creator>thezen</dc:creator>
      <dc:date>2018-10-08T00:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: conditional lookup with catch-all value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/conditional-lookup-with-catch-all-value/m-p/410619#M167218</link>
      <description>&lt;P&gt;Hi @thezen,&lt;/P&gt;

&lt;P&gt;Try below query&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourBaseSearch&amp;gt;
| lookup yourlookup.csv raw_field1 AS FIELD1, raw_field2 AS FIELD2 OUTPUT MATCHTAG AS MATCHTAG, UNMATCHEDTAG AS UNMATCHEDTAG 
| eval merged_tag = coalesce(MATCHTAG, UNMATCHEDTAG)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Oct 2018 10:01:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/conditional-lookup-with-catch-all-value/m-p/410619#M167218</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2018-10-08T10:01:53Z</dc:date>
    </item>
    <item>
      <title>Re: conditional lookup with catch-all value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/conditional-lookup-with-catch-all-value/m-p/410620#M167219</link>
      <description>&lt;P&gt;thanks but it doesn't seem to work in my case, I need all of the original events including the one which is not mached to be part of the result.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 04:50:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/conditional-lookup-with-catch-all-value/m-p/410620#M167219</guid>
      <dc:creator>thezen</dc:creator>
      <dc:date>2018-10-18T04:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: conditional lookup with catch-all value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/conditional-lookup-with-catch-all-value/m-p/410621#M167220</link>
      <description>&lt;P&gt;Managed to do it by using enabling wildcard on the field and then use mvindex to do catch-all.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 04:51:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/conditional-lookup-with-catch-all-value/m-p/410621#M167220</guid>
      <dc:creator>thezen</dc:creator>
      <dc:date>2018-10-18T04:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: conditional lookup with catch-all value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/conditional-lookup-with-catch-all-value/m-p/410622#M167221</link>
      <description>&lt;P&gt;You can try this , I don't know the field names so you will have t change in query accordingly&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=&amp;lt;yourindex&amp;gt; |join fields1[|inputlookup &amp;lt;yourlookup&amp;gt;.csv |rename FIELD2 as lookup_field2| fields Flookup_field2 MATCHED UNMATCHED]| eval string=if(field2= lookup_field2, MATCHED,UNMATCHED)| fields field1 field2 string
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Oct 2018 05:01:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/conditional-lookup-with-catch-all-value/m-p/410622#M167221</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2018-10-18T05:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: conditional lookup with catch-all value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/conditional-lookup-with-catch-all-value/m-p/410623#M167222</link>
      <description>&lt;P&gt;@thezen, If your problem is resolved, please accept an answer to help future readers.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 11:58:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/conditional-lookup-with-catch-all-value/m-p/410623#M167222</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2018-10-18T11:58:05Z</dc:date>
    </item>
  </channel>
</rss>

