<?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 Convert search value to field name for input to another search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Convert-search-value-to-field-name-for-input-to-another-search/m-p/70228#M17573</link>
    <description>&lt;P&gt;Is there a way to take a value from one lookup or search and make it the field name for the other.
Example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval idx=3
| lookup ltable1 idx OUTPUT location
| eval idx=5
| lookup ltable1 idx OUTPUT location AS location2
???| eval fname=value(location2) AS FIELD???
| lookup ltable2 location OUTPUT fname
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;example ltable1&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;idx,location
1,chi
2,lon,
3,nyc
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;ltable2&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;location,chi,lon,nyc
chi,NA,2,3
lon,6,NA,4
nyc,2,5,NA
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;wanting to Xref the 2 tables like a mileage matrix of sorts, therefore given chi as a value from ltable1 Xref to lon will get me 2.&lt;/P&gt;</description>
    <pubDate>Wed, 30 Mar 2011 01:52:29 GMT</pubDate>
    <dc:creator>tincupchalice</dc:creator>
    <dc:date>2011-03-30T01:52:29Z</dc:date>
    <item>
      <title>Convert search value to field name for input to another search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-search-value-to-field-name-for-input-to-another-search/m-p/70228#M17573</link>
      <description>&lt;P&gt;Is there a way to take a value from one lookup or search and make it the field name for the other.
Example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval idx=3
| lookup ltable1 idx OUTPUT location
| eval idx=5
| lookup ltable1 idx OUTPUT location AS location2
???| eval fname=value(location2) AS FIELD???
| lookup ltable2 location OUTPUT fname
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;example ltable1&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;idx,location
1,chi
2,lon,
3,nyc
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;ltable2&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;location,chi,lon,nyc
chi,NA,2,3
lon,6,NA,4
nyc,2,5,NA
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;wanting to Xref the 2 tables like a mileage matrix of sorts, therefore given chi as a value from ltable1 Xref to lon will get me 2.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2011 01:52:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-search-value-to-field-name-for-input-to-another-search/m-p/70228#M17573</guid>
      <dc:creator>tincupchalice</dc:creator>
      <dc:date>2011-03-30T01:52:29Z</dc:date>
    </item>
    <item>
      <title>Re: Convert search value to field name for input to another search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-search-value-to-field-name-for-input-to-another-search/m-p/70229#M17574</link>
      <description>&lt;P&gt;I think you can do what you want by having 2 lookups defined, where the results of one lookup are used in the next.    Here is a similar question  &lt;A href="http://splunk-base.splunk.com/answers/24816/can-i-chain-fields-together-between-two-different-lookups-csv-files"&gt;Can I chain fields together between two different lookups?&lt;/A&gt;  There is a nice discussion there.  Here's a summary, tailored to your specific question.  Edit props.conf as follows&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    ## props.conf
    LOOKUP-ltable1 = lookup_city_name idx OUTPUT location
    LOOKUP-ltable2 = lookup_distance location OUTPUT chi,lon,nyc
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But I think that a better way to arrange the second table might be&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  from,to,distance
  chi,lon,6
  lon,chi,6
  chi,ny,2
  ny,chi,2

  etc.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This duplicates the entries, because you need an entry for london-to-chicago as well as chicago-to-london, but it makes the logic easier.  Unless you are dealing with millions of entries, don't worry about performance.  &lt;/P&gt;

&lt;P&gt;If you do this, your second lookup could be&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  LOOKUP-ltable2 = lookup_distance from, to OUTPUT distance
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Jun 2011 18:27:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-search-value-to-field-name-for-input-to-another-search/m-p/70229#M17574</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2011-06-01T18:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: Convert search value to field name for input to another search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-search-value-to-field-name-for-input-to-another-search/m-p/70230#M17575</link>
      <description>&lt;P&gt;The second will work given a handful of locations, I guess I was trying to be too clever.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2011 19:22:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-search-value-to-field-name-for-input-to-another-search/m-p/70230#M17575</guid>
      <dc:creator>tincupchalice</dc:creator>
      <dc:date>2011-06-17T19:22:17Z</dc:date>
    </item>
  </channel>
</rss>

