Hey all, I need to write an equation that looks at a PI tag whose value is either 1 or 0 and returns to me the time stamp for the last event (ex. the time the value changed from 0 to 1). Can anyone help with this?

I tried this equation, but it's not returning the correct time for the event:

If('tagname')=”1” then

(PrevEvent('tagname','*+1s')) else ("0")

any ideas?

Thanks Kelsey and Dan! Here's what I used and it seems to be giving me exactly what I want:

If(('tagname')="Desired value") then

FindNE('tagname','*','*-10d',TagVal('tagname','*'))

else("Desired statement")