Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Habreu
New Member

Cohort retantion by churn

Hey there! 
So, my table has 3 date columns; Register date and Churn date.

I want to calculate the retention of each month, using the register date as cohort criterea, and, measure the number of clients that still using my app  by month using churn date as the date we lost the client. 

I dont know how to write this formula on DAX. 

This is an example of what i want:
In Jan, whe have 17 new clients. In may we lost 5 of our jan clients:

Habreu_0-1640130835059.png
tx

 

1 ACCEPTED SOLUTION
v-chenwuz-msft
Community Support
Community Support

Hi @Habreu ,

 

I create two calendar tables which have no relationship between them. X and Y .

Create table code:

X =
VAR _c =
    CALENDAR( DATE( 2021, 1, 1 ), DATE( 2021, 12, 31 ) )
RETURN
    ADDCOLUMNS( _c, "Xmonth", FORMAT( [Date], "mm/mmm/yy" ) )

Y the same as X.

And the matrix values use the following measure:

retention of each month =
VAR _S =
    FILTER(
        'Table',
        [RegisterDate] <= MAX( 'y'[Date] )
            && [RegisterDate] >= MIN( 'y'[Date] )
            && [ChurnDate] >= MIN( X[Date] )
    )
RETURN
    IF( MIN( X[Date] ) >= MIN( Y[Date] ), COUNTROWS( _S ), BLANK() )

Result:

vchenwuzmsft_0-1640334020848.png

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
mahoneypat
Microsoft Employee
Microsoft Employee

On the Modeling tab, click on New Table and enter this expression (adapt to match your current table and column name). There should be no relationship between the two tables.

 

ChurnDates = DISTINCT(Churn[ChurnDate])
 
Pat
 




Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


v-chenwuz-msft
Community Support
Community Support

Hi @Habreu ,

 

I create two calendar tables which have no relationship between them. X and Y .

Create table code:

X =
VAR _c =
    CALENDAR( DATE( 2021, 1, 1 ), DATE( 2021, 12, 31 ) )
RETURN
    ADDCOLUMNS( _c, "Xmonth", FORMAT( [Date], "mm/mmm/yy" ) )

Y the same as X.

And the matrix values use the following measure:

retention of each month =
VAR _S =
    FILTER(
        'Table',
        [RegisterDate] <= MAX( 'y'[Date] )
            && [RegisterDate] >= MIN( 'y'[Date] )
            && [ChurnDate] >= MIN( X[Date] )
    )
RETURN
    IF( MIN( X[Date] ) >= MIN( Y[Date] ), COUNTROWS( _S ), BLANK() )

Result:

vchenwuzmsft_0-1640334020848.png

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 
mahoneypat
Microsoft Employee
Microsoft Employee

To do that, you'll need to make a disconnected table with your Churn dates or months, using DISTINCT or VALUES, and then use that for the columns in your matrix (the ChurnDates[ChurnDate] in the measure). Then use a measure like this one.

 

mahoneypat_0-1640133033813.png

Remaining =
VAR thischurndate =
    MIN ( ChurnDates[ChurnDate] )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( Churn[Customer] ),
        FILTER ( ALL ( Churn[ChurnDate] ), Churn[ChurnDate] >= thischurndate )
    )

 

Pat

 

 

 

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hey Pat, fisrt, thanks for helping me. 

I am trying your solution, but i guess i am missing the step " make a disconnected table with your Churn dates or months, using DISTINCT or VALUES"  (because i dont know how).

And this is re result i am getting: 

Habreu_0-1640190654578.png

Here is how i build the matrix :
linhas (rows) : register date 

colunas(columns) : churn date
valores(values) remaining
I am using the same measure that you show to calculate remaings 

 

Habreu_1-1640190697773.png

 

tx matte

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.