<?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: Is it possible to pass an eval value to table command? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-pass-an-eval-value-to-table-command/m-p/314130#M94027</link>
    <description>&lt;P&gt;You can't pass a field value to a table command, but since your field names (in  your sample search) are static, you can use subsearch like this to achieve the same.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
 | eval field_a ="My Value A", field_b ="Other Value B" 
 | table [|makeresults |  eval search ="field_a field_b" | table search ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The 'search' is a special field name which will return the string value from the subsearch&lt;/P&gt;</description>
    <pubDate>Thu, 31 Aug 2017 13:57:44 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2017-08-31T13:57:44Z</dc:date>
    <item>
      <title>Is it possible to pass an eval value to table command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-pass-an-eval-value-to-table-command/m-p/314129#M94026</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a string with fields that I want to show in a table. (eval -&amp;gt; my_fields)&lt;/P&gt;

&lt;P&gt;This is my search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval my_fields ="field_a field_b"
| eval field_a ="My Value A", field_b ="Other Value B" 
| table my_fields
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And this is my search output:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;my_fields
field_a field_b
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But I want my result to be like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; field_a    | field_b
 My Value A | Other Value B
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How can I do this?&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 13:34:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-pass-an-eval-value-to-table-command/m-p/314129#M94026</guid>
      <dc:creator>raymondc</dc:creator>
      <dc:date>2017-08-31T13:34:41Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to pass an eval value to table command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-pass-an-eval-value-to-table-command/m-p/314130#M94027</link>
      <description>&lt;P&gt;You can't pass a field value to a table command, but since your field names (in  your sample search) are static, you can use subsearch like this to achieve the same.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
 | eval field_a ="My Value A", field_b ="Other Value B" 
 | table [|makeresults |  eval search ="field_a field_b" | table search ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The 'search' is a special field name which will return the string value from the subsearch&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 13:57:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-pass-an-eval-value-to-table-command/m-p/314130#M94027</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-08-31T13:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to pass an eval value to table command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-pass-an-eval-value-to-table-command/m-p/314131#M94028</link>
      <description>&lt;P&gt;You want to have one field that will determine which other fields will be displayed.&lt;/P&gt;

&lt;P&gt;Two easy ways, the first describing @somesoni2's above...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your first search that gets values of fieldA and fieldB and potentially other fields
| table [ search your second search that returns names of fieldA and fieldB in a field named search as the only field ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;.. . or the alternate...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your second search that returns names of fieldA and fieldB in a field named foo (and we dont care how many other fields) 
| map search="search your first search that gets values of fieldA, field B and potentially other fields | table $foo$"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Aug 2017 23:49:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-pass-an-eval-value-to-table-command/m-p/314131#M94028</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-08-31T23:49:00Z</dc:date>
    </item>
  </channel>
</rss>

