<?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 Indirect field reference in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Indirect-field-reference/m-p/466658#M131377</link>
    <description>&lt;P&gt;I've got a lookup table with counts by date. This table is updated each night, and I would like to search by the date fields relative to the current date. Example:&lt;/P&gt;

&lt;P&gt;5-26-2020 / 5-27-2020 / 5-28-2020&lt;BR /&gt;
12 / 30 / 15&lt;BR /&gt;
10 / 10 / 8&lt;BR /&gt;
19 / 12 / 15&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup counts.csv | eval today=strftime(_time,"%m-%d-%Y") | stats sum(**today**)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm thinking of something akin to the INDIRECT function in excel.&lt;/P&gt;</description>
    <pubDate>Thu, 28 May 2020 19:24:53 GMT</pubDate>
    <dc:creator>stephenmeyers</dc:creator>
    <dc:date>2020-05-28T19:24:53Z</dc:date>
    <item>
      <title>Indirect field reference</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Indirect-field-reference/m-p/466658#M131377</link>
      <description>&lt;P&gt;I've got a lookup table with counts by date. This table is updated each night, and I would like to search by the date fields relative to the current date. Example:&lt;/P&gt;

&lt;P&gt;5-26-2020 / 5-27-2020 / 5-28-2020&lt;BR /&gt;
12 / 30 / 15&lt;BR /&gt;
10 / 10 / 8&lt;BR /&gt;
19 / 12 / 15&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup counts.csv | eval today=strftime(_time,"%m-%d-%Y") | stats sum(**today**)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm thinking of something akin to the INDIRECT function in excel.&lt;/P&gt;</description>
      <pubDate>Thu, 28 May 2020 19:24:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Indirect-field-reference/m-p/466658#M131377</guid>
      <dc:creator>stephenmeyers</dc:creator>
      <dc:date>2020-05-28T19:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: Indirect field reference</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Indirect-field-reference/m-p/466659#M131378</link>
      <description>&lt;P&gt;If I understand correctly, you are saying that the field name is the date, in "%m-%d-%Y" order.  &lt;/P&gt;

&lt;P&gt;&lt;EM&gt;As an initial aside, please please please use ISO date order, you will save yourself loads of grief.  "2020-05-02" is unambiguous.  "05-02-2020" could be May 2 or Feb 5.&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;That being said, you are asking for the sum of all fields where the name of the field is a certain date.  You can use the &lt;CODE&gt;untable&lt;/CODE&gt; command to put the name of each field on a record into one field with an arbitrary name, and the value into a second field with a second arbitrary name. I picked "fieldname" and "fieldvalue" for the example, but the names could have been "fred" and "wilma".&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | inputlookup mydata.csv
 | stats sum(*) as * 
 | eval placebo=1
 | untable placebo fieldname fieldvalue 
 | where fieldname = strftime(_time,"%m-%d-%Y")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 May 2020 20:30:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Indirect-field-reference/m-p/466659#M131378</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2020-05-28T20:30:58Z</dc:date>
    </item>
    <item>
      <title>Re: Indirect field reference</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Indirect-field-reference/m-p/466660#M131379</link>
      <description>&lt;P&gt;There is something akin to indirection within &lt;CODE&gt;eval&lt;/CODE&gt;, but it doesn't do what you seek.&lt;/P&gt;

&lt;P&gt;Put &lt;CODE&gt;{}&lt;/CODE&gt; around a field name to treat that field as a "pointer" to another field.  For example,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval foo = "date" | eval {foo} = strftime (_time,"%m-%d-%Y")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;is a simplistic example that assigns the human-readable version of _time to the field called "date".  Imagine 'foo' is read from a data source and you may see the usefulness of it.&lt;/P&gt;

&lt;P&gt;I'm not aware of an SPL construct that lets you set the name of a field to a random string.&lt;/P&gt;

&lt;P&gt;Consider posting a use case for that ability at &lt;A href="https://ideas.splunk.com"&gt;https://ideas.splunk.com&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 May 2020 20:50:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Indirect-field-reference/m-p/466660#M131379</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-05-28T20:50:18Z</dc:date>
    </item>
  </channel>
</rss>

