<?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: Parsing a variable to a lookup command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Parsing-a-variable-to-a-lookup-command/m-p/751493#M242512</link>
    <description>&lt;P&gt;No. It doesn't "work everywhere". Some commands support field names as arguments, some don't - they need static values. Additionally dashboards support substituting tokens for values in SPL search but this is done by the dashboard mechanism _before_ the resulting search is spawned so the tokens are being substituted with actual values from the dashboard before the SPL is sent for execution.&lt;/P&gt;&lt;P&gt;To some extent you can sometimes do "dynamic programming" by generating part of your SPL with a subsearch as&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;showed or by using the map command (which is hardly ever the right solution) but most often it's just a case of rethinking your problem.&lt;/P&gt;&lt;P&gt;What is it you want to achieve? If you want to decide dynamically _per event_ which lookup to look up from, that will not work. Splunk doesn't do that. Running a subsearch-based lookup name assignment would yield just one lookup for your whole search.&lt;/P&gt;&lt;P&gt;The right technique here would be to run two lookups sequentially, populating two separate (sets of) fields and then in a subsequent eval assign dynamically the destination field to either of resulting values depending on your logical conditons.&lt;/P&gt;</description>
    <pubDate>Wed, 13 Aug 2025 06:00:15 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2025-08-13T06:00:15Z</dc:date>
    <item>
      <title>Parsing a variable to a lookup command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Parsing-a-variable-to-a-lookup-command/m-p/751405#M242503</link>
      <description>&lt;P&gt;Dear Splunk gurus&lt;/P&gt;&lt;P&gt;I am trying to get the lookup command to accept the lookup table name from a variable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&amp;nbsp;&lt;/P&gt;&lt;P&gt;| eval list2=case(like(llist, "%option1%"), "list_number_1", like(risklist, "%option2%"), "list_number_2")&lt;BR /&gt;| lookup list2 Name AS value&lt;/P&gt;&lt;P&gt;So... I successfully get the right lookup name. If I table out the list2 (|table list2), I can see that list2 equals the name of the right lookup ("list_number_1"). So the eval command works as intended.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I use "|lookup list_number_1 Name AS value" it works great.&amp;nbsp;&lt;BR /&gt;So the lookup command works as intended.&amp;nbsp;&lt;/P&gt;&lt;P&gt;But if I use "|lookup list2 Name AS value" it does not work even though "list2" = "list_number_1".&amp;nbsp;&lt;/P&gt;&lt;P&gt;So it seems the lookup command will not accept a variable even when the variable contains the name of a valid lookup file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;But can that be true? This works everywhere else in Splunk...&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Aug 2025 13:09:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Parsing-a-variable-to-a-lookup-command/m-p/751405#M242503</guid>
      <dc:creator>maigaard</dc:creator>
      <dc:date>2025-08-12T13:09:51Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing a variable to a lookup command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Parsing-a-variable-to-a-lookup-command/m-p/751410#M242504</link>
      <description>&lt;P&gt;Please can you give examples of what "this" is as in "&lt;SPAN&gt;This works everywhere else in Splunk"?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Having said that, if this is for use in a dashboard, you may be able to achieve your desired outcome with the use of tokens.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Aug 2025 13:37:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Parsing-a-variable-to-a-lookup-command/m-p/751410#M242504</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2025-08-12T13:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing a variable to a lookup command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Parsing-a-variable-to-a-lookup-command/m-p/751413#M242505</link>
      <description>&lt;P&gt;What I mean by "this works everywhere else" is that the use of variables as input works elsewhere.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is not for a dashboard, but is meant to be used in a saved search.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Aug 2025 14:31:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Parsing-a-variable-to-a-lookup-command/m-p/751413#M242505</guid>
      <dc:creator>maigaard</dc:creator>
      <dc:date>2025-08-12T14:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing a variable to a lookup command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Parsing-a-variable-to-a-lookup-command/m-p/751472#M242511</link>
      <description>&lt;P&gt;The use of variables does not work everywhere, but you can achieve this with a subsearch. If you wrap the eval statement as a subsearch to the lookup command it will work, i.e.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| lookup [ | makeresults | eval list2=case(like(llist, "%option1%"), "list_number_1", like(risklist, "%option2%"), "list_number_2") | return $list2 ] Name as value&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 13 Aug 2025 03:09:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Parsing-a-variable-to-a-lookup-command/m-p/751472#M242511</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2025-08-13T03:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing a variable to a lookup command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Parsing-a-variable-to-a-lookup-command/m-p/751493#M242512</link>
      <description>&lt;P&gt;No. It doesn't "work everywhere". Some commands support field names as arguments, some don't - they need static values. Additionally dashboards support substituting tokens for values in SPL search but this is done by the dashboard mechanism _before_ the resulting search is spawned so the tokens are being substituted with actual values from the dashboard before the SPL is sent for execution.&lt;/P&gt;&lt;P&gt;To some extent you can sometimes do "dynamic programming" by generating part of your SPL with a subsearch as&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;showed or by using the map command (which is hardly ever the right solution) but most often it's just a case of rethinking your problem.&lt;/P&gt;&lt;P&gt;What is it you want to achieve? If you want to decide dynamically _per event_ which lookup to look up from, that will not work. Splunk doesn't do that. Running a subsearch-based lookup name assignment would yield just one lookup for your whole search.&lt;/P&gt;&lt;P&gt;The right technique here would be to run two lookups sequentially, populating two separate (sets of) fields and then in a subsequent eval assign dynamically the destination field to either of resulting values depending on your logical conditons.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Aug 2025 06:00:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Parsing-a-variable-to-a-lookup-command/m-p/751493#M242512</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2025-08-13T06:00:15Z</dc:date>
    </item>
  </channel>
</rss>

