Hello,
I am trying to get some help here on my project.
the context:
1. If the user activity_month_date > min_activity_month_date - it means the user did not use the app between the min_activity_month_date to activity_month_date
2. We need this user to have per month per row from Min to Max activity month date period (dynamically changing) because we want to count the user in the denominator, so as long as this user's account still exists, we will count the user in the denominator for the given month.
I have trouble adding the rows to fill the gap here, I appreciate any help! thank you!
I have the input as below :
team_member_id | hire_date | account_creation_date | activity_month_date | Min_activity_month_date | Max_activity_month_date |
A | 2018-06-01 | 2018-05-18 | 2023-09-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2023-10-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2023-11-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2023-12-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2024-01-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2024-02-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2024-03-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2024-04-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2024-05-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2024-06-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2024-07-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2024-08-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2024-09-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2024-10-01 | 2023-07-01 | 2024-11-01 |
Expected output
team_member_id | hire_date | account_creation_date | activity_month_date | Min_activity_month_date | Max_activity_month_date |
A | 2018-06-01 | 2018-05-18 | 2023-07-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2023-08-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2023-09-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2023-10-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2023-11-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2023-12-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2024-01-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2024-02-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2024-03-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2024-04-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2024-05-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2024-06-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2024-07-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2024-08-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2024-09-01 | 2023-07-01 | 2024-11-01 |
A | 2018-06-01 | 2018-05-18 | 2024-10-01 | 2023-07-01 | 2024-11-01 |
Solved! Go to Solution.
Hi @zzhangs
Give this a shot, I grouped the data (minus your existing activity month field) and used the generate rows with a DateTimeAdd function to increment the months based on the min/max dates.