Forum Discussion
Cohort Analysis tutorial
- Anonymous7 years ago
Dear,
Thank you for your reply.
I want my result look like this in the picture attached.
I want to see the percentage of customer (%) and the number of customers who re-purchase after their first purchase.
I use the sample - superstore dataset(xls). I can't find the attach button here so I send you a link the has the dataset.
Please download it and help me to build Cohort Analysis in Power Bi.
Thanks for spending time to help me!
Based on your post, I assume you want to find the following
1) How many new customer IDs were created each quarter?
2) How many of them purchased in the subsequent quarters?
3) Show the ratio counts as a percentage.
For the sake of better understanding, I will illustrate the workings step by step so that you will get started on this and you will be able to modify the codes on your own to suit your requirements.
Add the following Columns to your "Orders" table.
Step1: Add a calculated column for Customer's First Purchase Date
CustomerFirstPurchaseDate =
MINX (
FILTER ( ALL ( Orders ), Orders[Customer ID] = EARLIER ( Orders[Customer ID] ) ),
Orders[Order Date]
)Step2: Add a calculated column for Order's Quarter No
OrderQtrNo =
VAR BaseYear =
YEAR ( MINX ( ALL ( Orders ), Orders[Order Date] ) )
VAR OrderYear =
YEAR ( Orders[Order Date] )
VAR MF = ( OrderYear - BaseYear ) * 4
RETURN
Orders[Order Date].[QuarterNo] + MFStep3: Add a calculated column for Customer's Q00
CustomerQ0 =
VAR BaseYear =
YEAR ( MINX ( ALL ( Orders ), Orders[Order Date] ) )
VAR CFPYear =
YEAR ( Orders[CustomerFirstPurchaseDate] )
VAR MF = ( CFPYear - BaseYear ) * 4
RETURN
Orders[CustomerFirstPurchaseDate].[QuarterNo] + MFStep4: Add a calculated column for Customer's 1st Quarter as text ( like 2014-Q3 etc...)
FirstQuarterOfCustomer = Orders[CustomerFirstPurchaseDate].[Year] & "-Q" & Orders[CustomerFirstPurchaseDate].[QuarterNo]
Step 5: Add a calculated column for Customer's Returning Quarters
ReturningQuarterNo =
"Q"
& FORMAT ( Orders[OrderQtrNo] - Orders[CustomerQ0], "00" )Step 6: Add a measure for finding the count of active customers.
ActiveCustomerCount = DISTINCTCOUNT(Orders[Customer ID])
Step 7: Add a measure to find the total number of customers activated each quarter.
TotalCustomers =
CALCULATE (
DISTINCTCOUNT ( Orders[Customer ID] ),
Orders[ReturningQuarterNo] = "Q00"
)Step 8: Add a measure to find the percentages
CA = DIVIDE([ActiveCustomerCount],[TotalCustomers],0)
Here is the result...
- Anonymous7 years agoNot applicable
Dear,
Thank you for your solution
I applied you formular in my company data
I got an error of QuarterNo for my Customer1stPurchase
I assumed that because of the date format. When I adjusted Date Format in C2C1stpurchase column, it changed to different result.
when I changed to Date format
I just tried the formular on sample_superstore; it gives the same error.
Did you tried it on data sample_superstore? If yes, Could you share me your file please?
Hope you help me to fix it!!Thanks
- Anonymous7 years agoNot applicable
- Anonymous7 years agoNot applicable
Dear,
Once again, thank you so much for spending time helping me!
I can solve it right now!
Many thanks and really appreciated
- Abdulmuqsit3 years agoRegular Visitor
share pbix file