<?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: Find maximum value in one column where a second column meets criteria in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Find-maximum-value-in-one-column-where-a-second-column-meets/m-p/528067#M149080</link>
    <description>&lt;P&gt;Sorry, missed that part.&lt;/P&gt;&lt;P&gt;What about this based on the test data ?&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval ml=mvrange(1,10)
| mvexpand ml
| eval achieved=random() % 2
| table ml achieved
| eventstats min(eval(if(achieved==0,ml-1,null()))) as max_ml&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 05 Nov 2020 07:04:21 GMT</pubDate>
    <dc:creator>renjith_nair</dc:creator>
    <dc:date>2020-11-05T07:04:21Z</dc:date>
    <item>
      <title>Find maximum value in one column where a second column meets criteria</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-maximum-value-in-one-column-where-a-second-column-meets/m-p/528040#M149068</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I believe as with all things Splunk, there is more than one way to solve this&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My data consists of this&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval ml=mvrange(1,4)
| mvexpand ml
| eval achieved=random() % 2
| table ml achieved&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want is to find the highest value of ml where achieved=1 and where there has not been achieved=0 in a lower value of ml.&lt;/P&gt;&lt;P&gt;I have worked out that this works, but I would like to see if there is a different solution as this seems a bit overly complicated&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval ml=mvrange(1,4)
| mvexpand ml
| eval achieved=random() % 2
| table ml achieved
| eval x=if(achieved=0,0,null)
| filldown x
| eventstats max(eval(if(isnull(x),ml,null))) as y
| head 1
| eval max_ml=if(isnull(y),0,y)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;where max_ml will give the desired outcome.&lt;/P&gt;&lt;P&gt;Anyone else see an alternative solution. Note mvrange size can be any size, so not just 3 values.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2020 00:02:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-maximum-value-in-one-column-where-a-second-column-meets/m-p/528040#M149068</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2020-11-05T00:02:32Z</dc:date>
    </item>
    <item>
      <title>Re: Find maximum value in one column where a second column meets criteria</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-maximum-value-in-one-column-where-a-second-column-meets/m-p/528045#M149070</link>
      <description>&lt;P&gt;Does this work?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval ml=mvrange(1,10)
| mvexpand ml
| eval achieved=random() % 2
| table ml achieved
| eventstats max(eval(if(achieved==1,ml,null()))) as max_achieved_ml ,min(eval(if(achieved==0,ml,null()))) as min_unachieved_ml&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;eventstats can be replaced with stats if you dont need other fields.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2020 01:22:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-maximum-value-in-one-column-where-a-second-column-meets/m-p/528045#M149070</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2020-11-05T01:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: Find maximum value in one column where a second column meets criteria</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-maximum-value-in-one-column-where-a-second-column-meets/m-p/528063#M149078</link>
      <description>&lt;P&gt;No that's not quite it. This image shows how the first 0 in the achieved column effectively locks the max_achieved to the level of the previous row, where the last '1' was&lt;/P&gt;&lt;P&gt;Like this&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bowesmana_0-1604554049727.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/11654i190EBA94DA698EA9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bowesmana_0-1604554049727.png" alt="bowesmana_0-1604554049727.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Essentially what I am trying to do is find the highest contiguously attained level (ml). So in the above image, even though there were 1s up to ml=8, the presence of the 0 at ml=4 means that all ml&amp;gt;3 are meaningless.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2020 05:29:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-maximum-value-in-one-column-where-a-second-column-meets/m-p/528063#M149078</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2020-11-05T05:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: Find maximum value in one column where a second column meets criteria</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-maximum-value-in-one-column-where-a-second-column-meets/m-p/528067#M149080</link>
      <description>&lt;P&gt;Sorry, missed that part.&lt;/P&gt;&lt;P&gt;What about this based on the test data ?&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval ml=mvrange(1,10)
| mvexpand ml
| eval achieved=random() % 2
| table ml achieved
| eventstats min(eval(if(achieved==0,ml-1,null()))) as max_ml&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2020 07:04:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-maximum-value-in-one-column-where-a-second-column-meets/m-p/528067#M149080</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2020-11-05T07:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: Find maximum value in one column where a second column meets criteria</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-maximum-value-in-one-column-where-a-second-column-meets/m-p/528212#M149138</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/136781"&gt;@renjith_nair&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Almost got it - yes, clearer and simpler than my original. However, your eventstats on its own is not quite sufficient to handle the all 1 case, so this is needed&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eventstats min(eval(if(achieved==0,ml-1,null()))) as max_ml max(ml) as highest_ml
| eval max_ml=if(isnull(max_ml),highest_ml,max_ml)&lt;/LI-CODE&gt;&lt;P&gt;to handle the null max_ml when all achieved values are 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;Thanks for your help - I was stuck in too many dimensions to see the simplicity&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2020 20:37:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-maximum-value-in-one-column-where-a-second-column-meets/m-p/528212#M149138</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2020-11-05T20:37:05Z</dc:date>
    </item>
  </channel>
</rss>

