<?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 can lookup be used to match default value in .csv table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/can-lookup-be-used-to-match-default-value-in-csv-table/m-p/320911#M95876</link>
    <description>&lt;P&gt;I have a csv lookup table with 3 columns, eg:&lt;BR /&gt;
input1,input2,output&lt;BR /&gt;
240,789,303456&lt;BR /&gt;
240,330,303457&lt;BR /&gt;
240,default,303458&lt;BR /&gt;
246,345,249580&lt;BR /&gt;
246,330,249589&lt;BR /&gt;
246,default,230444&lt;/P&gt;

&lt;P&gt;The fields to match on input1 and input2 are 3 digit numbers. If input1 matches (240 and 246 in this example) and then input2 matches, then this is a straightforward lookup comand; eg, 240 and 789 will output 303456. But say input1 is 240 and input2 is 389, I need it to match the "240,default,303458" in the table. How can I achieve it in splunk? Thanks.&lt;/P&gt;</description>
    <pubDate>Sat, 21 Oct 2017 15:32:50 GMT</pubDate>
    <dc:creator>romelrkhan</dc:creator>
    <dc:date>2017-10-21T15:32:50Z</dc:date>
    <item>
      <title>can lookup be used to match default value in .csv table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/can-lookup-be-used-to-match-default-value-in-csv-table/m-p/320911#M95876</link>
      <description>&lt;P&gt;I have a csv lookup table with 3 columns, eg:&lt;BR /&gt;
input1,input2,output&lt;BR /&gt;
240,789,303456&lt;BR /&gt;
240,330,303457&lt;BR /&gt;
240,default,303458&lt;BR /&gt;
246,345,249580&lt;BR /&gt;
246,330,249589&lt;BR /&gt;
246,default,230444&lt;/P&gt;

&lt;P&gt;The fields to match on input1 and input2 are 3 digit numbers. If input1 matches (240 and 246 in this example) and then input2 matches, then this is a straightforward lookup comand; eg, 240 and 789 will output 303456. But say input1 is 240 and input2 is 389, I need it to match the "240,default,303458" in the table. How can I achieve it in splunk? Thanks.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Oct 2017 15:32:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/can-lookup-be-used-to-match-default-value-in-csv-table/m-p/320911#M95876</guid>
      <dc:creator>romelrkhan</dc:creator>
      <dc:date>2017-10-21T15:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: can lookup be used to match default value in .csv table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/can-lookup-be-used-to-match-default-value-in-csv-table/m-p/320912#M95877</link>
      <description>&lt;P&gt;Hello @romelrkhan&lt;/P&gt;

&lt;P&gt;assuming 389=default, try this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=indexname |eval input2=if(input2=389,default,input2) | table input1 input2 output
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or give a more detailed background on the other fields.&lt;/P&gt;

&lt;P&gt;Hope it helps!&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sun, 22 Oct 2017 03:38:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/can-lookup-be-used-to-match-default-value-in-csv-table/m-p/320912#M95877</guid>
      <dc:creator>lloydknight</dc:creator>
      <dc:date>2017-10-22T03:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: can lookup be used to match default value in .csv table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/can-lookup-be-used-to-match-default-value-in-csv-table/m-p/320913#M95878</link>
      <description>&lt;P&gt;try this!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(your search ※Including input1,input2)
|join type=outer input1 [|inputlookup XXX.csv where input2=default|table input1,output]
|join type=outer input1,input2 [|inputlookup XXX.csv |table input1,input2,output]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 22 Oct 2017 04:28:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/can-lookup-be-used-to-match-default-value-in-csv-table/m-p/320913#M95878</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2017-10-22T04:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: can lookup be used to match default value in .csv table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/can-lookup-be-used-to-match-default-value-in-csv-table/m-p/320914#M95879</link>
      <description>&lt;P&gt;If "default" only appears in the column for  &lt;CODE&gt;input2&lt;/CODE&gt;, then I think this is a more efficient way of matching:&lt;BR /&gt;
&lt;CODE&gt;your base search | lookup youlookup.csv input1 OUTPUT input2 AS check_input2 output | where isnotnull(check_input2) | eval match=if(input2=check_input2 OR check_input2="default", 1, 0) | where match=1&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This won't work if "default" can appear in the column for  &lt;CODE&gt;input1&lt;/CODE&gt;. &lt;/P&gt;

&lt;P&gt;If you are open to changing the content of your lookup table, you might find it easier to convert the instances of  &lt;CODE&gt;default&lt;/CODE&gt; to a wildcard and use wildcard matching. It's not very well documented in the Splunk docs (at least not that I can find), but this other answer provides the structure you'd need: &lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/52580/can-we-use-wildcard-characters-in-a-lookup-table.html"&gt;https://answers.splunk.com/answers/52580/can-we-use-wildcard-characters-in-a-lookup-table.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 00:55:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/can-lookup-be-used-to-match-default-value-in-csv-table/m-p/320914#M95879</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-10-23T00:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: can lookup be used to match default value in .csv table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/can-lookup-be-used-to-match-default-value-in-csv-table/m-p/320915#M95880</link>
      <description>&lt;P&gt;@romelrkhan -  If the accepted version has any performance problems, then convert to using the &lt;CODE&gt;lookup&lt;/CODE&gt; verb with &lt;CODE&gt;OUTPUT&lt;/CODE&gt; for the first &lt;CODE&gt;lookup&lt;/CODE&gt; and &lt;CODE&gt;OUTPUTNEW&lt;/CODE&gt; for the second &lt;CODE&gt;lookup&lt;/CODE&gt;. &lt;/P&gt;

&lt;P&gt;Try this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; (your search ※Including input1A,input2A)
| lookup xxx.csv inputname1 as input1A inputname2 as input2A OUTPUT outputname1
| eval defaultname = "default"
| lookup xxx.csv inputname1 as input1A inputname2 as defaultname OUTPUTNEW outputname1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;&lt;STRONG&gt;Assumptions:&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;1) Your lookup table has fields inputname1 inputname2 and outputname1.  *(Please don't use keywords like &lt;CODE&gt;output&lt;/CODE&gt; for a field name, even in examples.  It makes puppies cry.) * &lt;/P&gt;

&lt;P&gt;2) Your main search returns fields named input1A and input2A.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Explanation:&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;3) &lt;CODE&gt;Lookup&lt;/CODE&gt; is significantly more efficient than a &lt;CODE&gt;join&lt;/CODE&gt; in this kind of situation. &lt;/P&gt;

&lt;P&gt;4) The &lt;CODE&gt;OUTPUTNEW&lt;/CODE&gt; keyword will prevent the second &lt;CODE&gt;lookup&lt;/CODE&gt; from even running if the first one has succeeded. so it should be significantly more efficient than even a one-outer-join version. &lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 02:29:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/can-lookup-be-used-to-match-default-value-in-csv-table/m-p/320915#M95880</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-10-23T02:29:56Z</dc:date>
    </item>
  </channel>
</rss>

