>> Download the sample (Power BI)
This sample:
-
Groups each customer into a “Join Month Cohort”, based on the month in which they made their first purchase
-
For each “Join Month Cohort”, groups the customers in that cohort into a monthly retention period group, based on how long that customer’s retention period is, or was.
-
A customer’s retention period is the number of days between the customer’s onboarding date and their next (second) purchase.
Dashboard - Snippet
Section titled “Dashboard - Snippet”
Data Model - Snippet
Section titled “Data Model - Snippet”
Measures - Cohort
Section titled “Measures - Cohort”Cohort Customers
Section titled “Cohort Customers”Cohort Customers =COUNTROWS ( Customer_Table )Cohort Month
Section titled “Cohort Month”Cohort Month =VAR JoinDate = [Join Date]RETURN CALCULATE ( SELECTEDVALUE ( Calendar_Table[Month & Year] ), FILTER ( ALL ( Calendar_Table ), Calendar_Table[Date] = JoinDate ) )// works in customer contextCohort Start Month
Section titled “Cohort Start Month”Cohort Start Month =VAR OnboardingDate = [Onboarding Date]RETURN CALCULATE ( SELECTEDVALUE ( Calendar_Table[Month & Year] ), FILTER ( ALL ( Calendar_Table ), Calendar_Table[Date] = [Onboarding Date] ) )Join Date
Section titled “Join Date”Join Date =MIN ( Sales_Table[Date] )// works in Customer ContextNo. of Unique Customers as a % of all Customers
Section titled “No. of Unique Customers as a % of all Customers”No. of Unique Customers as a % of all Customers =CALCULATE ( DIVIDE ( [No. of Unique Customers in Retention Period], [Unique Customers], 0 ), TREATAS ( VALUES ( Calendar_Table[Month & Year] ), Customer_Table[Join Month Cohort] ))No. of Unique Customers in Retention Period
Section titled “No. of Unique Customers in Retention Period”No. of Unique Customers in Retention Period =VAR CustomerDimension = VALUES ( Customer_Table[Customer] )RETURN IF ( SELECTEDVALUE ( 'Retention Period Monthly Cohorts'[Period] ) = 0, [Unique Customers], CALCULATE ( CALCULATE ( [Unique Customers], FILTER ( CustomerDimension, COUNTROWS ( FILTER ( 'Retention Period Monthly Cohorts', [Retention Days] > 'Retention Period Monthly Cohorts'[Min Days] && [Retention Days] <= 'Retention Period Monthly Cohorts'[Max Days] ) ) > 0 ) ), TREATAS ( VALUES ( Calendar_Table[Month & Year] ), Customer_Table[Join Month Cohort] ) ) )Onboarding Date
Section titled “Onboarding Date”Onboarding Date =CALCULATE ( [Join Date], ALL ( Sales_Table ), VALUES ( Customer_Table[Customer] ))Retention Days
Section titled “Retention Days”Retention Days =VALUE ( [Second Purchase Date] ) - VALUE ( [Onboarding Date] )Second Purchase Date
Section titled “Second Purchase Date”Second Purchase Date =CALCULATE ( MIN ( Sales_Table[Date] ), FILTER ( ALL ( Sales_Table ), Sales_Table[Date] > [Onboarding Date] ), VALUES ( Customer_Table[Customer] ))//looking for the min sale AFTER the initial first saleUnique Customers
Section titled “Unique Customers”Unique Customers =COUNTROWS ( VALUES ( Sales_Table[Customer] ) )Tables
Section titled “Tables”Calendar_Table
Section titled “Calendar_Table”Calendar_Table =GENERATE ( CALENDAR ( DATE ( 2017, 1, 1 ), DATE ( 2019, 12, 31 ) ), VAR currentDay = [Date] VAR Day = DAY ( currentDay ) VAR Month = MONTH ( currentDay ) VAR Year = YEAR ( currentDay ) RETURN ROW ( "Day", day, "Month", month, "Year", year ))Calculated Columns
Section titled “Calculated Columns”Join Date
Section titled “Join Date”Join Date =[Join Date]Join Month Cohort
Section titled “Join Month Cohort”Join Month Cohort =[Cohort Month]Join Month Index
Section titled “Join Month Index”Join Month Index =CALCULATE ( SELECTEDVALUE ( Calendar_Table[YearMonthInt] ) * 100, FILTER ( Calendar_Table, Calendar_Table[Month & Year] = 'Cohort Measures'[Cohort Start Month] ))