As you can see, the current expressions considers all rows with Lag = 1 even after the Lag value changes to 4 and then to 1, my requirement is only to consider latest rows with same lag values. If the Lag Value changes I do not wish to consider the others rows even with the same Lag Value.
Can the experts provide the correct expression to only include the latest rows (based on timeStamp2) that have a constant Lag value? Once the Lag value changes, later rows must not be included.
I hope this explanation helps clarify my requirements, but please let me know if further clarification is needed.