Thanks for your reply.
Unfortunately it is not possible to re-shape the data. I need to find a solution for this calculation as it is.
You can re-shape your data set within Tableau so it will be easy to calculate the difference in hours.
If you are using a .csv or excel file we could play with the data source filters, calculations, and a Join to prepare the data set
In this case, I'm using a .csv with similar data structure that you provided
After connecting that file to Tableau I will add a data source filter to keep all the "started" trigger rows
Then we create an Inner JOIN with the same file (drag an drop another instance of the same file to the right of the previous one)
The Join condition is on Id
I will rename the trigger field to "Trigger-Started" and "Trigger-Ended"
I will create a calculated field to use it as a filter, the idea here is to eliminate the duplicate rows that this Join condition returned.
This will be a boolean value, we want to keep all the rows that "Trigger-Started" is different to "Trigger-Ended" .
Add the new calculated field to the data source filter, keep the True values
Rename Timestamp fields to "Timestamp-Started" and "Timestamp-Ended" respectively
Now it is easy to get the difference in hours
NOTE: If you are connecting to a Database we could create some Custom SQL to prepare the dataset, of course, that would be different steps.
Attached .twbx file for reference
Let me know if this helps!
Book1.twbx 7.7 KB