Hello Alteryx community,
I'm working on a dataset containing dates, visitor IDs, and visit IDs, and my objective is to calculate the difference, in hours, between visits. Here's an example pertaining to a single visitor:
| Date | Time | Visitor_ID | Visit_ID |
| 2019-09-01 | 9:00:00 AM | 123456789 | A |
| 2019-09-01 | 10:00:00 AM | 123456789 | B |
| 2019-09-01 | 11:00:00 AM | 123456789 | C |
| 2019-09-02 | 4:00:00 PM | 123456789 | D |
| 2019-09-02 | 7:00:00 PM | 123456789 | E |
| 2019-09-03 | 3:00:00 PM | 123456789 | F |
As you can see, Visitor 123456789 visited my site in six different sessions over the course of three days. Of course, my dataset contains hundreds of thousands of Visitor_IDs, so it's not possible to break them out and work on them individually. Ultimately, I'd like to get to this:
| Date | Time | Visitor_ID | Visit_ID | Hours Since Last Visit |
| 2019-09-01 | 9:00:00 AM | 123456789 | A | First Visit |
| 2019-09-01 | 10:00:00 AM | 123456789 | B | 1 |
| 2019-09-01 | 11:00:00 AM | 123456789 | C | 1 |
| 2019-09-02 | 4:00:00 PM | 123456789 | D | 29 |
| 2019-09-02 | 7:00:00 PM | 123456789 | E | 3 |
| 2019-09-03 | 3:00:00 PM | 123456789 | F | 20 |
Hopefully my example here is straightforward. I've tried a few ways but what I seem to get stuck on is ensuring that the calculation of hours since last visit stays within the Visitor_ID, i.e. Alteryx does not just calculate the time difference between each row regardless of the ID that groups it.
As a final note, you can see that I marked the first row as 'First Visit.' For each Visitor_ID, there's going to be a row with nothing to calculate previous to it. I'm open to suggestions on the right way to label that, as obviously I don't want to set it to 0.