Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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:
tx
Solved! Go to Solution.
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:
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.
Hi,
Share the link from where i can download your PBI file.
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.
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
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:
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.
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.
Remaining =
VAR thischurndate =
MIN ( ChurnDates[ChurnDate] )
RETURN
CALCULATE (
DISTINCTCOUNT ( Churn[Customer] ),
FILTER ( ALL ( Churn[ChurnDate] ), Churn[ChurnDate] >= thischurndate )
)
Pat
To learn more about Power BI, follow me on Twitter or subscribe 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:
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
tx matte