<?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 use lookup file inside if statement in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/use-lookup-file-inside-if-statement/m-p/572539#M199545</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I'm trying to use a lookup file inside an if statement, and it doesn't return any data. I would appreciate it if anyone could help me. Thanks!&lt;/P&gt;&lt;P&gt;The lookup file has 4 columns (TenantName, tenantId, Region, DB) and my base search is returning 5 columns (_time, TenantName, tenantId, Region, Status). I need to find the database name (or DB) for each record, and it should be done by using tenantId in base search wherever tenantId is not "Unknown".&lt;/P&gt;&lt;PRE&gt;&amp;lt;base search&amp;gt;&lt;BR /&gt;| table _time TenantName tenantId Region Status&lt;BR /&gt;| eval&amp;nbsp;Database=if(tenantId!="Unknown", &lt;BR /&gt;[| inputlookup myLookup&lt;BR /&gt;| where tenantId=tenantId&lt;BR /&gt;| return $DB],&lt;BR /&gt;[| inputlookup myLookup&lt;BR /&gt;| where TenantName=TenantName&lt;BR /&gt;| return $DB])&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Oct 2021 21:08:26 GMT</pubDate>
    <dc:creator>Sharzi</dc:creator>
    <dc:date>2021-10-26T21:08:26Z</dc:date>
    <item>
      <title>use lookup file inside if statement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/use-lookup-file-inside-if-statement/m-p/572539#M199545</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I'm trying to use a lookup file inside an if statement, and it doesn't return any data. I would appreciate it if anyone could help me. Thanks!&lt;/P&gt;&lt;P&gt;The lookup file has 4 columns (TenantName, tenantId, Region, DB) and my base search is returning 5 columns (_time, TenantName, tenantId, Region, Status). I need to find the database name (or DB) for each record, and it should be done by using tenantId in base search wherever tenantId is not "Unknown".&lt;/P&gt;&lt;PRE&gt;&amp;lt;base search&amp;gt;&lt;BR /&gt;| table _time TenantName tenantId Region Status&lt;BR /&gt;| eval&amp;nbsp;Database=if(tenantId!="Unknown", &lt;BR /&gt;[| inputlookup myLookup&lt;BR /&gt;| where tenantId=tenantId&lt;BR /&gt;| return $DB],&lt;BR /&gt;[| inputlookup myLookup&lt;BR /&gt;| where TenantName=TenantName&lt;BR /&gt;| return $DB])&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 21:08:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/use-lookup-file-inside-if-statement/m-p/572539#M199545</guid>
      <dc:creator>Sharzi</dc:creator>
      <dc:date>2021-10-26T21:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: use lookup file inside if statement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/use-lookup-file-inside-if-statement/m-p/572544#M199547</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231048"&gt;@Sharzi&lt;/a&gt;&amp;nbsp;try this to return records where DB is &lt;STRONG&gt;NOT&lt;/STRONG&gt; "unknown"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;base_search  [ inputlookup myLookup | fields TenantName, tenantId | where tenantId!="Unknown" AND TenantName=TenantName] | lookup myLookup tenantId TenantName output TenantName, tenantId, Region, DB |
| table _time TenantName tenantId Region Status DB&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;updated reply to correct spellings and missing fields&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 21:23:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/use-lookup-file-inside-if-statement/m-p/572544#M199547</guid>
      <dc:creator>nmohammed</dc:creator>
      <dc:date>2021-10-26T21:23:01Z</dc:date>
    </item>
  </channel>
</rss>

