<?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: How do you indirectly access a field value? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-indirectly-access-a-field-value/m-p/387136#M112948</link>
    <description>&lt;P&gt;@doton&lt;/P&gt;

&lt;P&gt;In &lt;CODE&gt;foreach&lt;/CODE&gt;, it will only assign a value in field &lt;CODE&gt;c&lt;/CODE&gt; if the &lt;STRONG&gt;field name&lt;/STRONG&gt; match with the value of &lt;CODE&gt;c&lt;/CODE&gt; (which is contain the name of field) else it will assign it self's value ( means &lt;CODE&gt;c&lt;/CODE&gt; will assign value of &lt;CODE&gt;c&lt;/CODE&gt; only). This will not override the matched values. So it is basic if else concept.&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 08 Jan 2019 07:31:30 GMT</pubDate>
    <dc:creator>kamlesh_vaghela</dc:creator>
    <dc:date>2019-01-08T07:31:30Z</dc:date>
    <item>
      <title>How do you indirectly access a field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-indirectly-access-a-field-value/m-p/387132#M112944</link>
      <description>&lt;P&gt;In the following query, I want to use the value of &lt;CODE&gt;b&lt;/CODE&gt; as a field:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval a=1
| eval b="a"
| eval c=some_operation_based_on(b)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want &lt;CODE&gt;c&lt;/CODE&gt; to be equal to the value of &lt;CODE&gt;a&lt;/CODE&gt; i.e. 1 in this example.  I have tried using &lt;CODE&gt;foreach&lt;/CODE&gt; and &lt;CODE&gt;{field_name}&lt;/CODE&gt; but I wasn't able to achieve the result I want.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 12:02:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-indirectly-access-a-field-value/m-p/387132#M112944</guid>
      <dc:creator>doton</dc:creator>
      <dc:date>2019-01-07T12:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: How do you indirectly access a field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-indirectly-access-a-field-value/m-p/387133#M112945</link>
      <description>&lt;P&gt;@doton&lt;/P&gt;

&lt;P&gt;can u try like this &lt;CODE&gt;$result.b$&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 13:45:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-indirectly-access-a-field-value/m-p/387133#M112945</guid>
      <dc:creator>harishalipaka</dc:creator>
      <dc:date>2019-01-07T13:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: How do you indirectly access a field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-indirectly-access-a-field-value/m-p/387134#M112946</link>
      <description>&lt;P&gt;@doton&lt;BR /&gt;
Can you please try this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval a=1 
| eval b="a" 
| eval c="" 
| foreach * 
    [ eval c=if("&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"==b,&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;,c)]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can do any operations as per you requirement,&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 13:51:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-indirectly-access-a-field-value/m-p/387134#M112946</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-01-07T13:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do you indirectly access a field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-indirectly-access-a-field-value/m-p/387135#M112947</link>
      <description>&lt;P&gt;@kamlesh_vaghela, Thanks it works, but I don't understand how it works. If I understand correctly, &lt;CODE&gt;&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;&lt;/CODE&gt; will be replaced by filed names as &lt;CODE&gt;foreach&lt;/CODE&gt; loops through them. Thus when the field is &lt;CODE&gt;b&lt;/CODE&gt; the the &lt;CODE&gt;eval&lt;/CODE&gt; expression should be equal to &lt;CODE&gt;eval c=if("b"==b,b,c)&lt;/CODE&gt; and &lt;CODE&gt;b&lt;/CODE&gt; is equal to &lt;CODE&gt;"a"&lt;/CODE&gt; so &lt;CODE&gt;c&lt;/CODE&gt; should be equal to &lt;CODE&gt;"a"&lt;/CODE&gt;. In the next iteration of the loop it will became &lt;CODE&gt;eval c=if("c"==b,c,c)&lt;/CODE&gt; so it shouldn't change the value of &lt;CODE&gt;c&lt;/CODE&gt;. &lt;BR /&gt;
Can you please elaborate?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jan 2019 05:37:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-indirectly-access-a-field-value/m-p/387135#M112947</guid>
      <dc:creator>doton</dc:creator>
      <dc:date>2019-01-08T05:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: How do you indirectly access a field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-indirectly-access-a-field-value/m-p/387136#M112948</link>
      <description>&lt;P&gt;@doton&lt;/P&gt;

&lt;P&gt;In &lt;CODE&gt;foreach&lt;/CODE&gt;, it will only assign a value in field &lt;CODE&gt;c&lt;/CODE&gt; if the &lt;STRONG&gt;field name&lt;/STRONG&gt; match with the value of &lt;CODE&gt;c&lt;/CODE&gt; (which is contain the name of field) else it will assign it self's value ( means &lt;CODE&gt;c&lt;/CODE&gt; will assign value of &lt;CODE&gt;c&lt;/CODE&gt; only). This will not override the matched values. So it is basic if else concept.&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jan 2019 07:31:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-indirectly-access-a-field-value/m-p/387136#M112948</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-01-08T07:31:30Z</dc:date>
    </item>
    <item>
      <title>Re: How do you indirectly access a field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-indirectly-access-a-field-value/m-p/387137#M112949</link>
      <description>&lt;P&gt;Thanks, I was missing this point &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;if the field name match with the &lt;STRONG&gt;value&lt;/STRONG&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 08 Jan 2019 08:59:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-indirectly-access-a-field-value/m-p/387137#M112949</guid>
      <dc:creator>doton</dc:creator>
      <dc:date>2019-01-08T08:59:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do you indirectly access a field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-indirectly-access-a-field-value/m-p/387138#M112950</link>
      <description>&lt;P&gt;@doton&lt;/P&gt;

&lt;P&gt;Great.. &lt;BR /&gt;
Please  upvote and accept the answer to close this question.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jan 2019 10:11:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-indirectly-access-a-field-value/m-p/387138#M112950</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-01-08T10:11:11Z</dc:date>
    </item>
  </channel>
</rss>

