Hi, I would like to find out how to calculate the time difference between different events of the same asset ID (group by). My data is structured as such (see below) with no transaction IDs provided: Asset_ID _time Event_Status A001 2021-01-01 00:00:00 A A001 2021-01-01 00:01:00 B A001 2021-01-01 00:07:00 A A002 2021-01-01 00:01:00 B A002 2021-01-01 00:02:00 C A002 2021-01-01 00:09:00 A A002 2021-01-01 00:11:00 D A003 2021-01-01 00:00:00 B A003 2021-01-01 00:09:00 D ... Note: the event statuses can appear in any order time duration needs to be grouped by common asset ID for it to be meaningful It's intended that this be deployed in a live system, so event status values that aren't closed (last value for an asset) are to display the current elapsed time since that event occurred The desired output would be to compute the time duration between rows as such: 1 & 2 for Asset A001: 1min 2 & 3 for Asset A001: 6min 3 for Asset A001: running for X duration (based on current time) since 2021-01-01 00:07:00 4 & 5 for Asset A002: 1min 5 & 6 for Asset A002: 7min 6 & 7 for Asset A002: 2min 7 for Asset A002: running for X duration (based on current time) since 2021-01-01 00:11:00 8 & 9 for Asset A003: 9min 9 for Asset A003: running for X duration (based on current time) since 2021-01-01 00:09:00 ... I've previously tried experimenting using the "transaction" and "duration" functions but they don't seem to give the desired result. Any suggestions on how to resolve this would be greatly appreciated. Thanks.
... View more