<?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: weirdness using max() and min() in eval, operating on numeric multivalue fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/weirdness-using-max-and-min-in-eval-operating-on-numeric/m-p/16381#M2184</link>
    <description>&lt;P&gt;I downvoted this post because there are several inaccuracies with this answer.  A list of values in a field IS a multi-value field.  also, you can add a value to a multi-value field using &lt;CODE&gt;mvappend&lt;/CODE&gt; in &lt;CODE&gt;eval&lt;/CODE&gt;.  streamstats is not best in his situation.  transaction does not give a unique list, but rather lists all values like &lt;CODE&gt;list&lt;/CODE&gt; in &lt;CODE&gt;stats&lt;/CODE&gt;.&lt;/P&gt;</description>
    <pubDate>Wed, 18 Dec 2019 12:40:38 GMT</pubDate>
    <dc:creator>landen99</dc:creator>
    <dc:date>2019-12-18T12:40:38Z</dc:date>
    <item>
      <title>weirdness using max() and min() in eval, operating on numeric multivalue fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/weirdness-using-max-and-min-in-eval-operating-on-numeric/m-p/16377#M2180</link>
      <description>&lt;P&gt;It seems like if you I have a numeric multivalued field,  I should be able to use eval to take the max and min of the values per row. &lt;/P&gt;

&lt;P&gt;For example, I have a 'bytes' field on my events.  i form those events into transactions and now i have a nice multivalued 'bytes' field on my transaction rows.&lt;BR /&gt;
From here I'd like to get the max and min values of bytes per row,  ie so I end up with a single 'maxBytes' number per transaction row.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;my search&amp;gt; | transaction user | eval maxBytes=max(bytes)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However when I do this I end up with a multiValued maxBytes, and its exactly as though I had just done: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;my search&amp;gt; | transaction user | eval maxBytes=bytes
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there a reason for why it works this way or is there a workaround for it? &lt;/P&gt;</description>
      <pubDate>Tue, 29 Jun 2010 01:15:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/weirdness-using-max-and-min-in-eval-operating-on-numeric/m-p/16377#M2180</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2010-06-29T01:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: weirdness using max() and min() in eval, operating on numeric multivalue fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/weirdness-using-max-and-min-in-eval-operating-on-numeric/m-p/16378#M2181</link>
      <description>&lt;P&gt;After re-reading the docs, it does seem like this would be a nice feature request.  I think you have to use &lt;CODE&gt;stats&lt;/CODE&gt; and not &lt;CODE&gt;eval&lt;/CODE&gt; when you are using the &lt;CODE&gt;max()&lt;/CODE&gt; function this way.  It seems like you have to have a list of values for &lt;CODE&gt;max&lt;/CODE&gt; in &lt;CODE&gt;eval&lt;/CODE&gt; where as &lt;CODE&gt;stats&lt;/CODE&gt; &lt;CODE&gt;max()&lt;/CODE&gt; works fine with multi-valued fields.  (There does seem to be some lacking features for multi-value fields like this.  Another one would be that you can't simply add a value to a multi-value field without some ugly delimiter-based hacks.)&lt;/P&gt;

&lt;P&gt;Perhaps this would be the best fit for your situation: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ... | streamstats max(bytes) as maxBytes window=1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;BTW.  Make sure that use include &lt;CODE&gt;mvlist="bytes"&lt;/CODE&gt; on your &lt;CODE&gt;transaction&lt;/CODE&gt; command, or you will get a unique list of values for &lt;CODE&gt;bytes&lt;/CODE&gt; instead of a one-for-one listing of your &lt;CODE&gt;bytes&lt;/CODE&gt; values.  (I guess this really only matters if your doing &lt;CODE&gt;sum(bytes)&lt;/CODE&gt; or something like that, but this seems easy to overlook so I figured I point it out.)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jun 2010 01:17:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/weirdness-using-max-and-min-in-eval-operating-on-numeric/m-p/16378#M2181</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-06-29T01:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: weirdness using max() and min() in eval, operating on numeric multivalue fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/weirdness-using-max-and-min-in-eval-operating-on-numeric/m-p/16379#M2182</link>
      <description>&lt;P&gt;Thanks lowell.  Extremely helpful.  And I had not come across mvlist="bytes" yet, or noticed that transaction was only keeping distinct values by default.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2010 23:29:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/weirdness-using-max-and-min-in-eval-operating-on-numeric/m-p/16379#M2182</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2010-06-30T23:29:55Z</dc:date>
    </item>
    <item>
      <title>Re: weirdness using max() and min() in eval, operating on numeric multivalue fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/weirdness-using-max-and-min-in-eval-operating-on-numeric/m-p/16380#M2183</link>
      <description>&lt;P&gt;great answer, Lowell. Fit my needs aswell &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2013 08:41:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/weirdness-using-max-and-min-in-eval-operating-on-numeric/m-p/16380#M2183</guid>
      <dc:creator>stefano_guidoba</dc:creator>
      <dc:date>2013-09-17T08:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: weirdness using max() and min() in eval, operating on numeric multivalue fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/weirdness-using-max-and-min-in-eval-operating-on-numeric/m-p/16381#M2184</link>
      <description>&lt;P&gt;I downvoted this post because there are several inaccuracies with this answer.  A list of values in a field IS a multi-value field.  also, you can add a value to a multi-value field using &lt;CODE&gt;mvappend&lt;/CODE&gt; in &lt;CODE&gt;eval&lt;/CODE&gt;.  streamstats is not best in his situation.  transaction does not give a unique list, but rather lists all values like &lt;CODE&gt;list&lt;/CODE&gt; in &lt;CODE&gt;stats&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2019 12:40:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/weirdness-using-max-and-min-in-eval-operating-on-numeric/m-p/16381#M2184</guid>
      <dc:creator>landen99</dc:creator>
      <dc:date>2019-12-18T12:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: weirdness using max() and min() in eval, operating on numeric multivalue fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/weirdness-using-max-and-min-in-eval-operating-on-numeric/m-p/16382#M2185</link>
      <description>&lt;P&gt;First, transaction does not take the max, but instead lists all the value for each field in the order it encounters them much like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats list(field1) AS field1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Second, max is NOT used on a multivalue field, but rather on a comma-separated list like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval n=max(1, 3, 6, 7, "foo", foo2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;where "foo" is evaluated as greater than 0.&lt;BR /&gt;
Third, if you want the max of a multivalued field, use stats like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats max(field1) AS field1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Fourth, the accepted answer to this question about re-reading the docs and being a "nice feature request" has SO many inaccuracies that it really should be deleted.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2019 12:47:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/weirdness-using-max-and-min-in-eval-operating-on-numeric/m-p/16382#M2185</guid>
      <dc:creator>landen99</dc:creator>
      <dc:date>2019-12-18T12:47:50Z</dc:date>
    </item>
  </channel>
</rss>

