Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.
Hey guys,
I'm computing the 30 days churn rate and I've came across a calculation problem. Basically the total number is correct (I've checked it myself), however the columns numbers are not being correctly computed. The calculation is the following:
Churn =
VAR _NDaysCustomers =
CALCULATETABLE (
VALUES ( Fact[User] ),
DATEADD ( d_Calendar[Date], -30, DAY ),
USERELATIONSHIP ( d_Calendar[Date], Fact[End] )
)
VAR _IntervalCustomers =
CALCULATETABLE (
VALUES ( Fact[User] ),
DATESINPERIOD ( d_Calendar[Date], MIN ( d_Calendar[Date] ), -30, DAY )
)
VAR _Except =
COUNTROWS ( EXCEPT ( _NDaysCustomers, _intervalCustomers ) )
RETURN _Except
The following image shows what I got from the above calculation and what is the actually result, where the former is shown above and the latter being the bottom table.
There are slights differences, but these make the numbers wrong.
Any thoughts on where I'm doing my calculation wrong?
Hi,
It will help if you first explain the question in simple language, share some sample data (share only as many tables and columns within those tables as are required to solve this problem) and show the expected result based off the sample data table.
The very second line contains the file link, and also there's an image, a description of my problem and also the formula.
Thanks for your reply though
What do the payment, start and end columns represent?
The payment column stands for the payment method selected/used and the start and end columns represent the dates in which the subscription (or the plan) was active
Maybe i just cannot understand your question. Someone else will help you.
Thanks for your feedback, Ashish
Probably using-30 in one variable and -31 in another variable is causing the difference
Thanks for your response.
I've tried using both arguments as -30 and event then it didn't work. I posted it here with the difference you spoted, but i did not mean to. It was a mistake of my part.
Thanks for noticing
The other possibilities I can think of are using DATEADD in both or DATESINPERIOD in BOTH or
in the second variable, instead of MIN(d_CalendarDate), you may try MAX(d_CalendarDate)
Hey buddy, could you help me out with this topic, please?
Hello @Pedro503,
Could you please try the following:
Churn =
VAR _NDaysCustomers =
CALCULATETABLE (
VALUES ( Fact[User] ),
DATEADD ( d_Calendar[Date], -30, DAY ),
USERELATIONSHIP ( d_Calendar[Date], Fact[End] )
)
VAR _IntervalCustomers =
CALCULATETABLE (
VALUES ( Fact[User] ),
DATESINPERIOD ( d_Calendar[Date], MIN ( d_Calendar[Date] ), -31, DAY )
)
VAR _Except =
COUNTROWS ( EXCEPT ( _NDaysCustomers, _IntervalCustomers ) )
RETURN _Except
Let me know if you might still need further assistance.
➤ Email: sahir@sahirmaharaj.com
➤ Lets connect on LinkedIn: Join my network of 12K+ professionals
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30k readers! Sharing my knowledge about data science and artificial intelligence
Thanks for your response, @Sahir_Maharaj
I've just tried this piece of code you provided, but i didn't manage to get the expected outcome.
I appreciate your help
: )
@Pedro503 , Based on what I got , try like
Churn =
VAR _NDaysCustomers =
CALCULATETABLE (
VALUES ( Fact[User] ),
DATEADD ( d_Calendar[Date], -30, DAY ),
USERELATIONSHIP ( d_Calendar[Date], Fact[End] )
)
VAR _IntervalCustomers =
CALCULATETABLE (
VALUES ( Fact[User] ),
DATESINPERIOD ( d_Calendar[Date], MIN ( d_Calendar[Date] ), -31, DAY )
)
VAR _Except =
COUNTROWS ( EXCEPT ( _NDaysCustomers, _intervalCustomers ) )
RETURN sumx(values(d_Calendar[Date]), calculate(_Except) )
Thanks for your response, @amitchandak .
I just tried what you suggested, but unfortunately I got the very same result as the example I provided.
Check out the November 2023 Power BI update to learn about new features.
Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.