Hi Community,
I've searched the community for a solution, but my 'natural language processing' isn't up to scratch.
I'm trying to calculate the number of days leads spend in each phase of our sales funnel. The data is currently in the format below Table 1, however, I'd like it to look like Table 2 below. The calculations are calculated based on today's date (9 Jan 2019).
Challenges
- Depending on the complexity of the customer journey, there can be up to 100 phases/timestamps.
- Each journey is different. The number of columns is defined by the lead with the greatest number of phases.
- A timestamp is created every time a lead is opened/actioned. There can be multiple status/phase change timestamps in the same phase (e.g. See phase 2 and phase 3 below).
Objectives
- Get the data in the format of Table 2
- Calculate the total time in each unique phase (i.e. if a lead multiple status/phase change timestamps in the same phase, then calculate the total time in that phase).
Table 1
| Lead ID | Product Code | Sale_Start | UPDATE_ON | Phase 1 | Date 1 | Phase 2 | Date 2 | Phase 3 | Date 3 | Phase 4 | Date 4 |
| 1 | 12405 | 01/11/2018 | 04/01/2019 3:11:29 PM | Online Form | 02/11/2018 4:34:23 AM | Sales Contact | 02/11/2018 10:07:22 AM | Sales Contact | 02/11/2018 12:23:45 PM | Financial Clearance | 04/01/2019 3:11:29 PM |
| 2 | 90070 | 22/12/2018 | 02/01/2019 4:45:30 AM | | | | | | | | |
| 3 | 23451 | 27/11/2018 | 14/12/2018 12:44:38 PM | Online Form | 28/11/2018 4:33:07 AM | Financial Clearance | 28/11/2018 10:13:04 AM | | | | |
Table 2
| Lead ID | Product Code | Sale_Start | Phase 1 | Days in phase 1 | Phase 2 | Days in phase 2 | Phase 3 | Days in phase 3 |
| 1 | 12405 | 1/11/2018 | Online Form | 1 | Sales Contact | 0 | Financial Clearance | 63 |
| 2 | 90070 | 22/12/2018 | Application Received | 18 | | | | |
| 3 | 23451 | 27/11/2018 | Online Form | 1 | Financial Clearance | 0 | | |
Can anyone help me with this? Happy to answer any other questions or clarify the problem if required.
Thanks in advance,
Chris