<?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 to use return command in subsearch to return a multivalued field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-return-command-in-subsearch-to-return-a-multivalued/m-p/333491#M99187</link>
    <description>&lt;P&gt;@niketnilay basically the output is a table with single column &amp;amp; multiple rows. in this above example, &lt;STRONG&gt;data&lt;/STRONG&gt; is the column &amp;amp; it has like 100 rows with different values in each row&lt;/P&gt;</description>
    <pubDate>Wed, 25 Oct 2017 12:03:23 GMT</pubDate>
    <dc:creator>kabiraj</dc:creator>
    <dc:date>2017-10-25T12:03:23Z</dc:date>
    <item>
      <title>How to use return command in subsearch to return a multivalued field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-return-command-in-subsearch-to-return-a-multivalued/m-p/333489#M99185</link>
      <description>&lt;P&gt;I am trying to use &lt;CODE&gt;return&lt;/CODE&gt; command to output a multivalued field from subsearch to main search. My search looks like below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mysearch | eval field = [| inputlookup rest_of_search | return $fieldname]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here, &lt;STRONG&gt;fieldname&lt;/STRONG&gt; has multiple values in multiple rows but after running query it outputs &lt;STRONG&gt;only the value at first row to each of the rows&lt;/STRONG&gt; because of which i am getting same value in each row. I also tried below but it showed error:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mysearch | eval field = [| inputlookup rest_of_search | return 1000 $fieldname]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;where 1000 is the count of matched results.&lt;/P&gt;

&lt;P&gt;Any Solution?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 10:25:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-return-command-in-subsearch-to-return-a-multivalued/m-p/333489#M99185</guid>
      <dc:creator>kabiraj</dc:creator>
      <dc:date>2017-10-25T10:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to use return command in subsearch to return a multivalued field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-return-command-in-subsearch-to-return-a-multivalued/m-p/333490#M99186</link>
      <description>&lt;P&gt;@kabiraj, can you add sample data from your inputlookup which has multivalued field.&lt;/P&gt;

&lt;P&gt;Following is a run anywhere search for you to try out&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval
    [|  makeresults
    |  eval data="100;200"
    |  makemv data delim=","
    |  table data
    |  return data]
| makemv data delim=";"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In your case you can try out the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; mysearch 
| eval  
           [| inputlookup rest_of_search 
            | return 1000 fieldname]
| makemv fieldname delim=";"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Oct 2017 11:34:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-return-command-in-subsearch-to-return-a-multivalued/m-p/333490#M99186</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-10-25T11:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to use return command in subsearch to return a multivalued field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-return-command-in-subsearch-to-return-a-multivalued/m-p/333491#M99187</link>
      <description>&lt;P&gt;@niketnilay basically the output is a table with single column &amp;amp; multiple rows. in this above example, &lt;STRONG&gt;data&lt;/STRONG&gt; is the column &amp;amp; it has like 100 rows with different values in each row&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 12:03:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-return-command-in-subsearch-to-return-a-multivalued/m-p/333491#M99187</guid>
      <dc:creator>kabiraj</dc:creator>
      <dc:date>2017-10-25T12:03:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to use return command in subsearch to return a multivalued field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-return-command-in-subsearch-to-return-a-multivalued/m-p/333492#M99188</link>
      <description>&lt;P&gt;here is some sample data for the field:&lt;/P&gt;

&lt;P&gt;percent&lt;BR /&gt;
80&lt;BR /&gt;
0&lt;BR /&gt;
0&lt;BR /&gt;
0&lt;BR /&gt;
100&lt;BR /&gt;
0&lt;BR /&gt;
0&lt;BR /&gt;
50&lt;BR /&gt;
7.692308&lt;BR /&gt;
100&lt;BR /&gt;
33.333333&lt;BR /&gt;
17.391304&lt;BR /&gt;
0&lt;BR /&gt;
0&lt;BR /&gt;
14.285714&lt;/P&gt;

&lt;P&gt;percent is the column and rest are rows with values&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 12:06:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-return-command-in-subsearch-to-return-a-multivalued/m-p/333492#M99188</guid>
      <dc:creator>kabiraj</dc:creator>
      <dc:date>2017-10-25T12:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to use return command in subsearch to return a multivalued field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-return-command-in-subsearch-to-return-a-multivalued/m-p/333493#M99189</link>
      <description>&lt;P&gt;Hi @kabiraj, based on the details seems like you want to use the values returned by the inputlookup to perform filter in your base search. Also what you have mentioned as multivalue is actually several rows of a column with single value.&lt;/P&gt;

&lt;P&gt;I am hoping the field name in your lookup file is the same as what you intend to search in your base search (or else you would need to use &lt;CODE&gt;rename&lt;/CODE&gt; command). Your sample data seems to have duplicate values for percent so if you want to use unique values you should use &lt;CODE&gt;dedup&lt;/CODE&gt; command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; myBaseSearch [| inputlookup rest_of_search | dedup fieldname | table fieldname]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following is a run anywhere search based on Splunk's &lt;CODE&gt;_internal&lt;/CODE&gt; index and &lt;CODE&gt;makeresults&lt;/CODE&gt; command instead of &lt;CODE&gt;lookup&lt;/CODE&gt; file, to explain the above search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal sourcetype=splunkd 
    [| makeresults
    |  eval log_level="WARN,ERROR,FATAL"
    |  makemv log_level delim=","
    |  mvexpand log_level
    |  table log_level]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The &lt;CODE&gt;makeresults&lt;/CODE&gt; command is used to generate a &lt;CODE&gt;log_level&lt;/CODE&gt; field (column) with three rows i.e. WARN, ERROR AND FATAL. Placing this in base search under square braces actually implies the following search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal sourcetype=splunkd log_level="WARN" OR log_level="ERROR" OR log_level="FATAL" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please try out and confirm. If you are looking for something else you will have to provide more details.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 09:59:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-return-command-in-subsearch-to-return-a-multivalued/m-p/333493#M99189</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-10-26T09:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to use return command in subsearch to return a multivalued field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-return-command-in-subsearch-to-return-a-multivalued/m-p/333494#M99190</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/201110"&gt;@niketn&lt;/a&gt; No, This is not what i am looking for. &lt;/P&gt;

&lt;P&gt;mysearch | eval field = [| inputlookup rest_of_search | return $fieldname]&lt;/P&gt;

&lt;P&gt;in this spl, ideally the values under "fieldname" should be assigned to field "field", which i am getting fine but the problem is with the values. It copies the value of first row to all the rows &amp;amp; then assigns it to field "field" because of which i am getting the same value in all the rows in field "field" which is incorrect.&lt;/P&gt;

&lt;P&gt;then i tried &lt;/P&gt;

&lt;P&gt;mysearch | eval field = [| inputlookup rest_of_search | return &lt;STRONG&gt;1000&lt;/STRONG&gt; $fieldname]&lt;/P&gt;

&lt;P&gt;1000 is the count of rows which it should consider uniquely while copying. By default its 1 because of which only first row get copied to all rows.&lt;/P&gt;

&lt;P&gt;But this spl gives me error in eval&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:29:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-return-command-in-subsearch-to-return-a-multivalued/m-p/333494#M99190</guid>
      <dc:creator>kabiraj</dc:creator>
      <dc:date>2020-09-29T16:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to use return command in subsearch to return a multivalued field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-return-command-in-subsearch-to-return-a-multivalued/m-p/333495#M99191</link>
      <description>&lt;P&gt;@kabiraj - &lt;/P&gt;

&lt;P&gt;Are you trying to get a single value out of the lookup that is appropriate to each value on the input record?  If so, then use this syntax&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| lookup mylookupname lookupfieldname OUTPUT outputfieldnamefromlookup
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If not, then I think you may be trying to do something in a way that won't work. But it is kind fo hard to figure out what that might be.  Please back up and update the question with an explanation of the overall purpose of your search, what is in the lookup, and what you hope this structure will achieve.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 18:34:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-return-command-in-subsearch-to-return-a-multivalued/m-p/333495#M99191</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-10-26T18:34:57Z</dc:date>
    </item>
  </channel>
</rss>

