<?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: for each column return max value and row key value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/for-each-column-return-max-value-and-row-key-value/m-p/487466#M136230</link>
    <description>&lt;P&gt;Thanks for your reply, it works.&lt;/P&gt;</description>
    <pubDate>Wed, 15 Jan 2020 19:50:37 GMT</pubDate>
    <dc:creator>wsabry</dc:creator>
    <dc:date>2020-01-15T19:50:37Z</dc:date>
    <item>
      <title>for each column return max value and row key value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/for-each-column-return-max-value-and-row-key-value/m-p/487464#M136228</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have SPL search that returns output in the following format:&lt;/P&gt;

&lt;P&gt;Device  K1  K2  K3&lt;BR /&gt;
A       x1  y1  z1&lt;BR /&gt;
B       x2  y2  z2&lt;BR /&gt;
C       x3  y3  z3&lt;/P&gt;

&lt;P&gt;I would like to generate table with max value of each column and row key value (Device in my example above), so the output should be in the following format:&lt;BR /&gt;
Key  Max        Device&lt;BR /&gt;
k1   x1             A&lt;BR /&gt;
k2   y3             C&lt;BR /&gt;
k3   z3             C&lt;/P&gt;

&lt;P&gt;I can find the max value of each column using fieldsummary for example, but then the device id is missing.&lt;BR /&gt;
How can I do that, thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2020 21:32:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/for-each-column-return-max-value-and-row-key-value/m-p/487464#M136228</guid>
      <dc:creator>wsabry</dc:creator>
      <dc:date>2020-01-14T21:32:09Z</dc:date>
    </item>
    <item>
      <title>Re: for each column return max value and row key value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/for-each-column-return-max-value-and-row-key-value/m-p/487465#M136229</link>
      <description>&lt;P&gt;hello there,&lt;/P&gt;

&lt;P&gt;here is a clumsy solution, try the following search anywhere.&lt;BR /&gt;
I bet there are better ways, its just been a very long day &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults count=1
| eval data="A 1 5 10;;;B 2 11 8;;;C 3 23 4;;;D 91 2 21;;;E 7 1 200;;;F 74 22 11"
| makemv delim=";;;" data 
| mvexpand data
| rex field=data "(?&amp;lt;device&amp;gt;[^\s]+)\s(?&amp;lt;k1&amp;gt;[^\s]+)\s(?&amp;lt;k2&amp;gt;[^\s]+)\s(?&amp;lt;k3&amp;gt;[^\s]+)"
| table device k*
| rename COMMENT as "the above generates data below is the solution" 
| eval no_op = " "
| xyseries no_op device k1 k2 k3
| transpose
| rename column as base "row 1" as values
| rex field=base "(?&amp;lt;key&amp;gt;[^\:]+)\:\s+(?&amp;lt;device&amp;gt;.*+)"
| eventstats max(values) as max_values by key
| where max_values = values
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;hope it helps&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2020 03:15:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/for-each-column-return-max-value-and-row-key-value/m-p/487465#M136229</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2020-01-15T03:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: for each column return max value and row key value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/for-each-column-return-max-value-and-row-key-value/m-p/487466#M136230</link>
      <description>&lt;P&gt;Thanks for your reply, it works.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2020 19:50:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/for-each-column-return-max-value-and-row-key-value/m-p/487466#M136230</guid>
      <dc:creator>wsabry</dc:creator>
      <dc:date>2020-01-15T19:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: for each column return max value and row key value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/for-each-column-return-max-value-and-row-key-value/m-p/487467#M136231</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="device k1  k2  k3
A   1   5   10
B   2   11  8
C   3   23  4
D   91  2   21
E   7   1   200
F   74  22  11"
| multikv forceheader=1 
| table device k*
| rename COMMENT as "the above generates data below is the solution"
| stats list(*) as * 
| untable device Key Max 
| eval counter=mvfind(split(Max," "),max(split(Max," "))) 
| eval device=mvindex(device,counter), Max=mvindex(split(Max," "),counter) 
| table Key device Max
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi @wsabry&lt;BR /&gt;
Here is another way.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2020 22:21:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/for-each-column-return-max-value-and-row-key-value/m-p/487467#M136231</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-15T22:21:22Z</dc:date>
    </item>
    <item>
      <title>Re: for each column return max value and row key value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/for-each-column-return-max-value-and-row-key-value/m-p/487468#M136232</link>
      <description>&lt;P&gt;cool &lt;CODE&gt;xyseries&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2020 22:47:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/for-each-column-return-max-value-and-row-key-value/m-p/487468#M136232</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-15T22:47:42Z</dc:date>
    </item>
  </channel>
</rss>

