I have a column :EVENT (character-nominal) with various values. Also another column :datetime (numeric-continuous). I have :datetime column sorted ascending. I am interested in having another column calculate for whenever there is a "CONNECT" event, what is the time difference between it and the last "DISCONNECT" event. The issue is that the lag can vary between a CONNECT and previous DISCONNECT (see photo below) and I'd also prefer keeping this tall table format. A solution for datetime sorted-ascending is appreciated, but also not sorted would also be beneficial.
