<?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 Field data from fieldname in variable in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Field-data-from-fieldname-in-variable/m-p/346848#M102684</link>
    <description>&lt;P&gt;Any way of achieving this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval Column1="MyData"
| eval TestField="Column1"
| eval Result{TestField}=if('{TestField}'="MyData",1,0)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The reason is simple. I want to define a lookup with all the fieldnames (columns) that is required for a specific category of events.&lt;BR /&gt;
My current search is larger than this, but i have found this example to describe my problem the best. if i solve this i can solve the rest. The result should be that ResultColumn1 = 1&lt;/P&gt;

&lt;P&gt;{TestField} works on the left side of = but not on the right side in the eval.&lt;BR /&gt;
I tried every combination of TestField including (',",$,$$,&amp;lt;&amp;lt;) but i am not able to retrieve the data from the field which is defined in TestField. &lt;BR /&gt;
If i use {TestField} on the right side of = i get an error. This is why i have put  '{TestField}' in my example above. &lt;/P&gt;

&lt;P&gt;I am using Enterprise 7.0.1&lt;/P&gt;

&lt;P&gt;Any help is appreciated.&lt;/P&gt;</description>
    <pubDate>Tue, 17 Apr 2018 17:03:28 GMT</pubDate>
    <dc:creator>auradk</dc:creator>
    <dc:date>2018-04-17T17:03:28Z</dc:date>
    <item>
      <title>Field data from fieldname in variable</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-data-from-fieldname-in-variable/m-p/346848#M102684</link>
      <description>&lt;P&gt;Any way of achieving this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval Column1="MyData"
| eval TestField="Column1"
| eval Result{TestField}=if('{TestField}'="MyData",1,0)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The reason is simple. I want to define a lookup with all the fieldnames (columns) that is required for a specific category of events.&lt;BR /&gt;
My current search is larger than this, but i have found this example to describe my problem the best. if i solve this i can solve the rest. The result should be that ResultColumn1 = 1&lt;/P&gt;

&lt;P&gt;{TestField} works on the left side of = but not on the right side in the eval.&lt;BR /&gt;
I tried every combination of TestField including (',",$,$$,&amp;lt;&amp;lt;) but i am not able to retrieve the data from the field which is defined in TestField. &lt;BR /&gt;
If i use {TestField} on the right side of = i get an error. This is why i have put  '{TestField}' in my example above. &lt;/P&gt;

&lt;P&gt;I am using Enterprise 7.0.1&lt;/P&gt;

&lt;P&gt;Any help is appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2018 17:03:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-data-from-fieldname-in-variable/m-p/346848#M102684</guid>
      <dc:creator>auradk</dc:creator>
      <dc:date>2018-04-17T17:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: Field data from fieldname in variable</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-data-from-fieldname-in-variable/m-p/346849#M102685</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
 | eval Column1="MyData"
 | eval TestField="Column1"
 | eval Result{TestField}=""
 | foreach Result* [| eval "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"=if('&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;'="MyData",1,0)]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Apr 2018 17:48:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-data-from-fieldname-in-variable/m-p/346849#M102685</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-04-17T17:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: Field data from fieldname in variable</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-data-from-fieldname-in-variable/m-p/346850#M102686</link>
      <description>&lt;P&gt;Thank you so much - i battled with that all day &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
It worked like a charm and even made my other query more simpel.&lt;BR /&gt;
I see now that i simply did not understand the documentation of foreach. Now i do.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2018 21:56:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-data-from-fieldname-in-variable/m-p/346850#M102686</guid>
      <dc:creator>auradk</dc:creator>
      <dc:date>2018-04-17T21:56:33Z</dc:date>
    </item>
  </channel>
</rss>

