Hi all,
I am trying to create a table showing the current retention against initial month of purchase.
Using pivot tables I can find the percentage difference against the previous month but not against the initial month.
This is my data (simplified):
Date | User | First Purchase | Type | Amount | Q.ty |
---|---|---|---|---|---|
01/07/2022 10:00 | 001 | 01/02/22 09:20 | Purchase | 50 | 1 |
01/07/2022 12:00 | 001 | 01/02/22 09:20 | Sale | 50 | 1 |
02/07/2022 09:38 | 001 | 01/01/22 09:20 | Purchase | 100 | 2 |
03/07/2022 15:46 | 002 | 03/01/22 20:20 | Purchase | 50 | 1 |
04/07/2022 12:10 | 003 | 04/07/22 12:10 | Purchase | 50 | 1 |
04/07/2022 19:50 | 004 | 19/06/22 05:01 | Purchase | 50 | 1 |
So I’ve got a table with different transactions (at daily level) and I also have the users first purchase date field, which is what I care about.
A pivot table aggregating data by month would look like this (let’s assume it’s only three months):
First Purchase Month | 2022-05 | 2022-06 | 2022-07 |
---|---|---|---|
2022-05 | 200 | 150 | 100 |
2022-06 | NULL | 120 | 90 |
2022-07 | NULL | NULL | 250 |
Which means that in May we had 200 First-time-purchasers. Then 150 of these made a purchase in June, so 75%, while in July, 100 of those initial 200 made a purchase, so it’s 50%.
The table would then look like this:
First Purchase Month | 2022-05 | 2022-06 | 2022-07 |
---|---|---|---|
2022-05 | 100% | 75% | 50% |
2022-06 | NULL | 100% | 75% |
2022-07 | NULL | NULL | 100% |
(Showing NULL instead of 100% for the first month works as well.)
Is there any way to get this in QuickSight?
I am thinking that I would need to use distinctCountOver pre-aggregating the data, but the fact that I’ve daily data and need to pre-aggregate it monthly is throwing me off, I was guessing I could use formatDate and Extract but I cannot find the way to make it work (if that is even the way).
Thank you!