<?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: get row value when the last 3 value is the same in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/get-row-value-when-the-last-3-value-is-the-same/m-p/514921#M9173</link>
    <description>&lt;P&gt;thank you sir. it work.&amp;nbsp; you are a legend&lt;/P&gt;</description>
    <pubDate>Wed, 19 Aug 2020 11:31:09 GMT</pubDate>
    <dc:creator>adcom26</dc:creator>
    <dc:date>2020-08-19T11:31:09Z</dc:date>
    <item>
      <title>get row value when the last 3 value is the same</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/get-row-value-when-the-last-3-value-is-the-same/m-p/514863#M9171</link>
      <description>&lt;P&gt;&lt;SPAN&gt;hello&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;i have a table like this&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;&lt;STRONG&gt;ID&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="35.13978494623656%" height="25px"&gt;&lt;STRONG&gt;ACTION&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="31.52688172043011%" height="25px"&gt;&lt;STRONG&gt;USER&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;1&lt;/TD&gt;&lt;TD width="35.13978494623656%" height="25px"&gt;success&lt;/TD&gt;&lt;TD width="31.52688172043011%" height="25px"&gt;Admin&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;2&lt;/TD&gt;&lt;TD width="35.13978494623656%" height="25px"&gt;success&lt;/TD&gt;&lt;TD width="31.52688172043011%" height="25px"&gt;user2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;3&lt;/TD&gt;&lt;TD width="35.13978494623656%" height="25px"&gt;Fail&lt;/TD&gt;&lt;TD width="31.52688172043011%" height="25px"&gt;user2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;4&lt;/TD&gt;&lt;TD width="35.13978494623656%" height="25px"&gt;Fail&lt;/TD&gt;&lt;TD width="31.52688172043011%" height="25px"&gt;user2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;5&lt;/TD&gt;&lt;TD width="35.13978494623656%" height="25px"&gt;Fail&lt;/TD&gt;&lt;TD width="31.52688172043011%" height="25px"&gt;user2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;6&lt;/TD&gt;&lt;TD width="35.13978494623656%" height="25px"&gt;success&lt;/TD&gt;&lt;TD width="31.52688172043011%" height="25px"&gt;user2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;7&lt;/TD&gt;&lt;TD width="35.13978494623656%" height="25px"&gt;Fail&lt;/TD&gt;&lt;TD width="31.52688172043011%" height="25px"&gt;Admin&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;8&lt;/TD&gt;&lt;TD width="35.13978494623656%" height="25px"&gt;Fail&lt;/TD&gt;&lt;TD width="31.52688172043011%" height="25px"&gt;Admin&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;9&lt;/TD&gt;&lt;TD width="35.13978494623656%" height="25px"&gt;Fail&lt;/TD&gt;&lt;TD width="31.52688172043011%" height="25px"&gt;user2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;10&lt;/TD&gt;&lt;TD width="35.13978494623656%" height="25px"&gt;Fail&lt;/TD&gt;&lt;TD width="31.52688172043011%" height="25px"&gt;user2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;11&lt;/TD&gt;&lt;TD width="35.13978494623656%" height="25px"&gt;Fail&lt;/TD&gt;&lt;TD width="31.52688172043011%" height="25px"&gt;Admin&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;12&amp;nbsp;&lt;/TD&gt;&lt;TD width="35.13978494623656%"&gt;Fail&amp;nbsp;&lt;/TD&gt;&lt;TD width="31.52688172043011%"&gt;user2&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;13&lt;/TD&gt;&lt;TD&gt;Fail&lt;/TD&gt;&lt;TD&gt;user2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if I want to show by users all the action (success) if the last 3 previous action = fail&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;the result shoud show :&lt;BR /&gt;&lt;BR /&gt;--the raw with (id = 1 ==&amp;gt; because the admin in her previous status have 3 fail (id=7, id=8, id=11)&amp;nbsp;&lt;BR /&gt;--the raw with (id = 2 ==&amp;gt; because the&amp;nbsp; user2 in her previous status have 3 fail (id= 3, id =4, id=5)&lt;BR /&gt;--the raw with (id = 6 ==&amp;gt; because the&amp;nbsp; user2 in her previous status have 3 fail (id= 9, id=10, id=12)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;and if I want&amp;nbsp;&lt;SPAN&gt;to show by users all the action (fail) if the last 3 previous action = fail&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;the result shoud show :&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;--the raw with (id = 9 ==&amp;gt;&amp;nbsp;because the&amp;nbsp; user2 in her previous status have 3 fail (id=10, id=12, id= 13 )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Aug 2020 08:13:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/get-row-value-when-the-last-3-value-is-the-same/m-p/514863#M9171</guid>
      <dc:creator>adcom26</dc:creator>
      <dc:date>2020-08-19T08:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: get row value when the last 3 value is the same</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/get-row-value-when-the-last-3-value-is-the-same/m-p/514888#M9172</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/223280"&gt;@adcom26&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;This took some cpu time from my brain :).&lt;BR /&gt;Not sure if is possible with less SPL, but it should work with:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval ID = "1 2 3 4 5 6 7 8 9 10 11 12 13" 
| makemv ID
| mvexpand ID
| eval action = case(ID=1,"success",ID=2,"success",ID=3,"fail",ID=4,"fail",ID=5,"fail",ID=6,"success",ID=7,"fail",ID=8,"fail",ID=9,"fail",ID=10,"fail",ID=11,"fail",ID=12,"fail",ID=13,"fail")
| eval user = case(ID=1,"admin",ID=2,"user2",ID=3,"user2",ID=4,"user2",ID=5,"user2",ID=6,"user2",ID=7,"admin",ID=8,"admin",ID=9,"user2",ID=10,"user2",ID=11,"admin",ID=12,"user2",ID=13,"user2")

| sort - user, ID
| streamstats count BY action, user reset_after="("match(action,\"success\")")"
| streamstats current=false window=1 first(action) as prev_action first(count) as prev_count first(user) as prev_user
| eval success=if(action="success" AND prev_action="fail" AND prev_count&amp;gt;=3 AND user=prev_user,"true","false")
| eval fail=if(action="fail" AND prev_action="fail" AND prev_count&amp;gt;=3 AND user=prev_user,"true","false")
| where success="true" OR fail="true"
| fields - prev* fail success
| sort ID&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You only need the lines starting with the first &lt;EM&gt;sort&lt;/EM&gt; command. The lines above that are just to create a table with your sample data.&lt;BR /&gt;&lt;BR /&gt;I think there is one problem with the "failed" ones. The SPL would output all lines after one user "collected" 3 fails, as I don't reset the "fails" after the first 3 where found. So what I mean is, that it would show the 4th "fail" for a user, but also the 5th and the 6th etc., if there is no "success" in between....If that is wrong, the "reset after" clause would have to be somehow extended.&lt;BR /&gt;&lt;BR /&gt;Hope it helps.&lt;BR /&gt;BR&lt;BR /&gt;Ralph&lt;BR /&gt;--&lt;BR /&gt;&lt;EM&gt;Karma and/or Solution tagging appreciated.&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Aug 2020 09:51:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/get-row-value-when-the-last-3-value-is-the-same/m-p/514888#M9172</guid>
      <dc:creator>rnowitzki</dc:creator>
      <dc:date>2020-08-19T09:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: get row value when the last 3 value is the same</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/get-row-value-when-the-last-3-value-is-the-same/m-p/514921#M9173</link>
      <description>&lt;P&gt;thank you sir. it work.&amp;nbsp; you are a legend&lt;/P&gt;</description>
      <pubDate>Wed, 19 Aug 2020 11:31:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/get-row-value-when-the-last-3-value-is-the-same/m-p/514921#M9173</guid>
      <dc:creator>adcom26</dc:creator>
      <dc:date>2020-08-19T11:31:09Z</dc:date>
    </item>
  </channel>
</rss>

