This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
I have a large set of customer data, and I need to get the longest number of consecutive visited days for each customer, as well as, the date of their most recent visit. The most recent visit is easy, but I'm having trouble calculating the longest consecutive visit.
For instance a customer might have visits for Jan 1st 2017 through Jan 9th 2017 (9 consecutive days) then not visit again until Feb 1st 2017 and visit for 10 days (Feb 1st - 10th) That same customer might then miss a few days and then visit again for 3 consecutive days. (Feb 20th - Feb 20rd)
Essential I would like to end up with three fields Cust ID | Most consecutive visits | Last visit
The attached workflow should do the trick! If you sort by the customer ID and then the Visit date, you can then creating a running total of consecutive visits using the Multi Row Formula. Then using the summarize tool you can get the maximum number of consecutive and the most recent visit.
Hope this helps and let me know if you have any questions!
See attached for a possible solution! Uses a few Multi-Row tools to determine if a date is consecutive to the one before & after, and then a few Summarize tools to group/sum/max to get the results you desire... hope that helps!
EDIT: Though @nick_ceneviva solution, while the same concept, is way more streamlined... you should use that one :)
Thank you both for replying! Nicole I wasn't able to open yours as well. However, Nick's is working.
In the multi-line formula I can't tell how its determining that the new consecutive days count is greater or less than the existing. (It seems to be working though). I'm just trying to learn. can you explain?
So its not actually checking against other consecutive streaks. It is just a running total and then the summarize tool takes the max consecutive days. So the output would look something similar to this coming out of the Multi Row Formula tool:
Consecutive Visits (From Multi Line)
If all of the above records are for the same customer, the max consecutive visits is 4. Hope that helps!