Numbered rows similar to row-over-partition function in SQL
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello Alteryx community:
I'd like to number rows in a method that's similar to the row-over-partition function. I've checked a few of the other threads on this topic and they didn't work quite right, because I think I have an added wrinkle. Here's my dataset:
Date | Hour | Visitor_ID | Visit_ID |
2019-09-01 | 9 | 123456789 | ACBDEF1 |
2019-09-01 | 11 | 123456789 | ACBDEF2 |
2019-09-01 | 20 | 123456789 | ACBDEF3 |
2019-09-02 | 1 | 123456789 | ACBDEF4 |
2019-09-02 | 8 | 123456789 | ACBDEF5 |
Visitor_ID 123456789 comes to my site three times on September 1st and twice on September 2. Each visit has a unique identifier applied to it. What I'd like to do is count each visit based on the day, by ascending hour. The resulting dataset shoud look something like:
Date | Hour | Visitor_ID | Visit_ID | Visit_Num |
2019-09-01 | 9 | 123456789 | ABCDEF1 | 1 |
2019-09-01 | 11 | 123456789 | ABCDEF2 | 2 |
2019-09-01 | 20 | 123456789 | ABCDEF3 | 3 |
2019-09-02 | 1 | 123456789 | ABCDEF4 | 1 |
2019-09-02 | 8 | 123456789 | ABCDEF5 | 2 |
Visit_ID ABCDEF1 is the first visit of Visitor_ID 123456789 on September 1, and then the count resets on the next day, where Visit_ID ABCDEF5 is the first visit of September 2.
I would appreciate help with this question!
(P.S. Of course, the data does not neatly line up like this. In my dataset, there are hundreds of thousands of Visitor_IDs and Visit_IDs, so it wouldn't be as simple as extracting one Visitor_ID and working individually on them.)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
