<?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 create a column/field based on the max or value of another column in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-column-field-based-on-the-max-or-value-of/m-p/403634#M116782</link>
    <description>&lt;P&gt;@HattrickNZ add the following as your final pipe:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;yourCurrentSearch&amp;gt;
| eventstats max(Q) as W
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 18 May 2018 04:41:32 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2018-05-18T04:41:32Z</dc:date>
    <item>
      <title>How to create a column/field based on the max or value of another column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-column-field-based-on-the-max-or-value-of/m-p/403632#M116780</link>
      <description>&lt;P&gt;This is my sample search and corresponding output:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | makeresults 
    | eval data = "
    1    2017-12    A    155749    131033    84.1;
   2    2017-12    B    24869    23627    95;
   3    2017-12    C    117618    117185    99.6;
   " 
    | makemv delim=";" data 
    | mvexpand data
    | rex field=data "(?&amp;lt;serial&amp;gt;\d)\s+(?&amp;lt;date&amp;gt;\d+-\d+)\s+(?&amp;lt;type&amp;gt;\w)\s+(?&amp;lt;attempts&amp;gt;\d+)\s+(?&amp;lt;successfullAttempts&amp;gt;\d+)\s+(?&amp;lt;sr&amp;gt;\d+)"
    | fields + date serial type attempts successfullAttempts sr 
    | rename date as _time 
    | search serial=*
| eval Q=attempts
| eval Q=if(Q==24869,"",Q)
| eval Q=if(Q==117618,"",Q)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OUTPUT&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    _time   serial  type    attempts    successfullAttempts sr  Q
1   2017-12 1   A   155749  131033  84  155749
2   2017-12 2   B   24869   23627   95  
3   2017-12 3   C   117618  117185  99  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to be able to get the value of Q(e.g. 155749 ) and create a new field called W but all the values of W would be 155749. Basically, fill out all the values in W with one value and that value being 155749, the max of Q in this case.&lt;/P&gt;

&lt;P&gt;Sample Output of what I would like &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    _time   serial  type    attempts    successfullAttempts sr  Q   W
1   2017-12 1   A   155749  131033  84  155749   155749
2   2017-12 2   B   24869   23627   95             155749
3   2017-12 3   C   117618  117185  99           155749
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I was thinking of doing &lt;CODE&gt;... | eval W=max(Q)&lt;/CODE&gt; but that won't work but hopefully helps understand what I am trying to do.&lt;BR /&gt;
maybe I need to use streamstats or other. I couldn't quite get it. Maybe I need a for loop? advice appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 18 May 2018 03:30:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-column-field-based-on-the-max-or-value-of/m-p/403632#M116780</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2018-05-18T03:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a column/field based on the max or value of another column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-column-field-based-on-the-max-or-value-of/m-p/403633#M116781</link>
      <description>&lt;P&gt;Can you try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
     | eval data = "
     1    2017-12    A    155749    131033    84.1;
    2    2017-12    B    24869    23627    95;
    3    2017-12    C    117618    117185    99.6;
    " 
     | makemv delim=";" data 
     | mvexpand data
     | rex field=data "(?&amp;lt;serial&amp;gt;\d)\s+(?&amp;lt;date&amp;gt;\d+-\d+)\s+(?&amp;lt;type&amp;gt;\w)\s+(?&amp;lt;attempts&amp;gt;\d+)\s+(?&amp;lt;successfullAttempts&amp;gt;\d+)\s+(?&amp;lt;sr&amp;gt;\d+)"
     | fields + date serial type attempts successfullAttempts sr 
     | rename date as _time 
     | search serial=*
 | eval Q=attempts
 | eval Q=if(Q==24869,"",Q)
 | eval Q=if(Q==117618,"",Q)
 | eventstats max(Q) AS W
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 May 2018 04:39:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-column-field-based-on-the-max-or-value-of/m-p/403633#M116781</guid>
      <dc:creator>p_gurav</dc:creator>
      <dc:date>2018-05-18T04:39:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a column/field based on the max or value of another column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-column-field-based-on-the-max-or-value-of/m-p/403634#M116782</link>
      <description>&lt;P&gt;@HattrickNZ add the following as your final pipe:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;yourCurrentSearch&amp;gt;
| eventstats max(Q) as W
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 May 2018 04:41:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-column-field-based-on-the-max-or-value-of/m-p/403634#M116782</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-05-18T04:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a column/field based on the max or value of another column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-column-field-based-on-the-max-or-value-of/m-p/403635#M116783</link>
      <description>&lt;P&gt;@HattrickNZ if your issue is resolved, please accept @p_gurav 's answer as he had beaten me to it &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 May 2018 05:54:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-column-field-based-on-the-max-or-value-of/m-p/403635#M116783</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-05-21T05:54:30Z</dc:date>
    </item>
  </channel>
</rss>

