@ITWhisperer I think I got it. I'm getting exactly as many records as I have # of B events. Can you just confirm that my logic makes sense? I added 1 more streamstats and changed the one with the reset_after: | streamstats count(eval(event=="B")) as reset_count by mac
| streamstats count as row by mac reset_count
| where row=2 AND isnotnull(previousaip) AND event="A" AND reset_count != 0 Making the full search, using your dummy data: | gentimes start=-1 increment=1h
| rename starttime as _time
| streamstats count as row
| eval event=mvindex(split("B",""),(row+2)%5)
| eval mac="mac".mvindex(split("ABC",""),floor((row-1)/10)%3)
| fillnull value="A" event
| eval flag=if(event="A",random()%10,null())
| eval ip="10.".(random()%10).".".(random()%10).".".(random()%256)
| table event mac ip flag
| streamstats count as row
| append
[| gentimes start=-1 increment=1h
| rename starttime as _time
| streamstats count as row
| eval event=mvindex(split("B",""),(row+2)%5)
| eval mac="mac".mvindex(split("DEF",""),floor((row-1)/10)%3)
| fillnull value="A" event
| eval flag=if(event="A",random()%10,null())
| eval ip="10.".(random()%10).".".(random()%10).".".(random()%256)
| table event mac ip flag
| streamstats count as row
]
| sort 0 row
| fields - row
| eval aip=if(event="A",ip,null())
| eval bip=if(event="B",ip,null())
| streamstats last(aip) as previousaip last(flag) as previousflag last(bip) as previousbip by mac current=f
| streamstats count(eval(event=="B")) as reset_count by mac
| streamstats count as row by mac reset_count
| where row=2 AND isnotnull(previousaip) AND event="A" AND reset_count != 0
| table event mac ip previousaip previousbip previousflag
... View more