<?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 find the max value based on the rows? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-max-value-based-on-the-rows/m-p/317289#M94920</link>
    <description>&lt;P&gt;How do you actually get the max column other than typing all that out after the below?&lt;/P&gt;

&lt;P&gt;This is what the user has. How do we add a max field to it?&lt;BR /&gt;
    | makeresults&lt;BR /&gt;
    | eval Date="12/08", shiftA=102, shiftB=10, shiftC=200&lt;BR /&gt;
    | append &lt;BR /&gt;
    [| makeresults&lt;BR /&gt;
    | eval Date="25/08", shiftA=240, shiftB=102, shiftC=52]&lt;BR /&gt;
    | append &lt;BR /&gt;
    [| makeresults&lt;BR /&gt;
    | eval Date="15/08", shiftA=158, shiftB=15, shiftC=178]&lt;BR /&gt;
    | table Date shift*&lt;BR /&gt;
    | transpose header_field=Date &lt;/P&gt;

&lt;P&gt;Or in other words is there a way to dynamically get the max without having to specify the field names? Or what do I have to add here, dynamically, to get the max?&lt;/P&gt;</description>
    <pubDate>Mon, 23 Apr 2018 23:02:39 GMT</pubDate>
    <dc:creator>HattrickNZ</dc:creator>
    <dc:date>2018-04-23T23:02:39Z</dc:date>
    <item>
      <title>How to find the max value based on the rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-max-value-based-on-the-rows/m-p/317281#M94912</link>
      <description>&lt;P&gt;Hi all,&lt;BR /&gt;
I want max value by row wise not &lt;STRONG&gt;max (field name)&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;**Date**           **shiftA**     **shiftB**     **shiftC**    **Max**
12/08                     102                   10                     200               200
25/08                     240                   102                   52                  240
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want like this. Please help for this. I want it urgent.&lt;BR /&gt;
Thanks &lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 09:32:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-max-value-based-on-the-rows/m-p/317281#M94912</guid>
      <dc:creator>harishalipaka</dc:creator>
      <dc:date>2017-09-05T09:32:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the max value based on the rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-max-value-based-on-the-rows/m-p/317282#M94913</link>
      <description>&lt;P&gt;Hi, you would need to use &lt;CODE&gt;foreach&lt;/CODE&gt; command to iterate through your fields in every row to compute Max. Following is the run anywhere search which mocks the data in this example and applies foreach. Pipes till &lt;CODE&gt;| table Date shift*&lt;/CODE&gt; generate the mock data. You need the two pipes after that.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval Date="12/08", shiftA=102, shiftB=10, shiftC=200
| append 
    [| makeresults
     | eval  Date="25/08", shiftA=240, shiftB=102, shiftC=52]
| table Date shift*
| eval Max=0
| foreach shift*
    [eval Max=case(Max&amp;gt;=&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;,Max,true(),&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Sep 2017 09:50:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-max-value-based-on-the-rows/m-p/317282#M94913</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-09-05T09:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the max value based on the rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-max-value-based-on-the-rows/m-p/317283#M94914</link>
      <description>&lt;P&gt;what about this FIELD ..?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 09:54:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-max-value-based-on-the-rows/m-p/317283#M94914</guid>
      <dc:creator>harishalipaka</dc:creator>
      <dc:date>2017-09-05T09:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the max value based on the rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-max-value-based-on-the-rows/m-p/317284#M94915</link>
      <description>&lt;P&gt;thanks for your replay sorry i want like this ..below is my query &lt;STRONG&gt;(dates not unique chaged based on query)&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;| makeresults&lt;BR /&gt;
 | eval Date="12/08", shiftA=102, shiftB=10, shiftC=200&lt;BR /&gt;
 | append &lt;BR /&gt;
     [| makeresults&lt;BR /&gt;
      | eval  Date="25/08", shiftA=240, shiftB=102, shiftC=52]&lt;BR /&gt;
| append &lt;BR /&gt;
     [| makeresults&lt;BR /&gt;
      | eval  Date="15/08", shiftA=158, shiftB=15, shiftC=178]&lt;BR /&gt;
 | table Date shift*&lt;BR /&gt;
  | transpose header_field=Date&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 10:01:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-max-value-based-on-the-rows/m-p/317284#M94915</guid>
      <dc:creator>harishalipaka</dc:creator>
      <dc:date>2017-09-05T10:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the max value based on the rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-max-value-based-on-the-rows/m-p/317285#M94916</link>
      <description>&lt;P&gt;Would it be possible for you to give us your existing query? What is the final transfoming command you have used to build your table?&lt;BR /&gt;
I am converting answer to comment. Since this is not resolved yet and we would require more details from your end. You can perform a &lt;CODE&gt;transpose&lt;/CODE&gt; on above data so that above answer works for you. However, I feel it is better if we handled it directly.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 11:01:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-max-value-based-on-the-rows/m-p/317285#M94916</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-09-05T11:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the max value based on the rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-max-value-based-on-the-rows/m-p/317286#M94917</link>
      <description>&lt;P&gt;with your makeresults, if you're doing a transpose before trying to calculate the max, you can try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval Date="12/08", shiftA=102, shiftB=10, shiftC=200
| append 
[| makeresults
| eval Date="25/08", shiftA=240, shiftB=102, shiftC=52]
| append 
[| makeresults
| eval Date="15/08", shiftA=158, shiftB=15, shiftC=178]
| table Date shift*
| transpose header_field=Date
 | appendpipe
     [eventstats max(*) as * |dedup column]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Sep 2017 11:57:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-max-value-based-on-the-rows/m-p/317286#M94917</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-09-05T11:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the max value based on the rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-max-value-based-on-the-rows/m-p/317287#M94918</link>
      <description>&lt;P&gt;As per updated info, following query generates Data in required format. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval Date="12/08", shiftA=102, shiftB=10, shiftC=200
| append 
[| makeresults
| eval Date="25/08", shiftA=240, shiftB=102, shiftC=52]
| append 
[| makeresults
| eval Date="15/08", shiftA=158, shiftB=15, shiftC=178]
| table Date shift*
| transpose header_field=Date
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Pipe the following to your &lt;CODE&gt;transpose&lt;/CODE&gt; to generate required stats:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| foreach */*
     [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=case(len('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')=3,'&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',len('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')=2,"0".'&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',len('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')=1,"00".'&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')]
| foreach */*
     [eval key_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;='&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'."-".Shift]
| fields key_*
| eventstats max(*) as *
| head 1
| transpose column_name="Date"
| eval Date=replace(Date,"key_","")
| eval "row 1"=split('row 1',"-")
| eval Value=mvindex('row 1',0)
| eval Shift=mvindex('row 1',1)
| fields - "row 1"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Sep 2017 12:22:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-max-value-based-on-the-rows/m-p/317287#M94918</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-09-05T12:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the max value based on the rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-max-value-based-on-the-rows/m-p/317288#M94919</link>
      <description>&lt;P&gt;This is my answer...&lt;BR /&gt;
    | makeresults&lt;BR /&gt;
    | eval Date="12/08", shiftA=102, shiftB=10, shiftC=200&lt;BR /&gt;
    | append &lt;BR /&gt;
    [| makeresults&lt;BR /&gt;
    | eval Date="25/08", shiftA=240, shiftB=102, shiftC=52]&lt;BR /&gt;
    | append &lt;BR /&gt;
    [| makeresults&lt;BR /&gt;
    | eval Date="15/08", shiftA=158, shiftB=15, shiftC=178]&lt;BR /&gt;
    | table Date shift*&lt;BR /&gt;
    | transpose header_field=Date | appendcols [ | makeresults&lt;BR /&gt;
    | eval Date="12/08", shiftA=102, shiftB=10, shiftC=200&lt;BR /&gt;
    | append &lt;BR /&gt;
    [| makeresults&lt;BR /&gt;
    | eval Date="25/08", shiftA=240, shiftB=102, shiftC=52]&lt;BR /&gt;
    | append &lt;BR /&gt;
    [| makeresults&lt;BR /&gt;
    | eval Date="15/08", shiftA=158, shiftB=15, shiftC=178]&lt;BR /&gt;
    | table Date shift*| stats max(shiftA) AS Total ,max(shiftB) as ttt ,max(shiftC) as cc | transpose 10 |rename "row 1" as "All"]&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2017 08:08:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-max-value-based-on-the-rows/m-p/317288#M94919</guid>
      <dc:creator>harishalipaka</dc:creator>
      <dc:date>2017-09-07T08:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the max value based on the rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-max-value-based-on-the-rows/m-p/317289#M94920</link>
      <description>&lt;P&gt;How do you actually get the max column other than typing all that out after the below?&lt;/P&gt;

&lt;P&gt;This is what the user has. How do we add a max field to it?&lt;BR /&gt;
    | makeresults&lt;BR /&gt;
    | eval Date="12/08", shiftA=102, shiftB=10, shiftC=200&lt;BR /&gt;
    | append &lt;BR /&gt;
    [| makeresults&lt;BR /&gt;
    | eval Date="25/08", shiftA=240, shiftB=102, shiftC=52]&lt;BR /&gt;
    | append &lt;BR /&gt;
    [| makeresults&lt;BR /&gt;
    | eval Date="15/08", shiftA=158, shiftB=15, shiftC=178]&lt;BR /&gt;
    | table Date shift*&lt;BR /&gt;
    | transpose header_field=Date &lt;/P&gt;

&lt;P&gt;Or in other words is there a way to dynamically get the max without having to specify the field names? Or what do I have to add here, dynamically, to get the max?&lt;/P&gt;</description>
      <pubDate>Mon, 23 Apr 2018 23:02:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-max-value-based-on-the-rows/m-p/317289#M94920</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2018-04-23T23:02:39Z</dc:date>
    </item>
  </channel>
</rss>

