Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowTry your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now
Hi Fam,
I am working on a retention chart. The idea is to know on a daily basis how many customers are churned and retained.
The logic is:
Customers who ordered between day-60 to day-31 ago from today and still order between day-30 to day-1 (today) are considered retained, they are churned otherwise.
Today is day 1
Yesterday is day 2
9 July 2023 is day 30
8 July 2023 is day 31
9 June 2023 is day 60
In my orders table, I have the following columns:
1. order_id (unique)
2. customer_id (unique)
3. time_pickup_date
The thing is, I want to start day 1 based on the date filter I set.
Then, I want to visualize it where x-axis is the date, y-axis is count of customers (distinct). Legend is churn and retained.
Solved! Go to Solution.
Hi @Andrew_na_lang ,
Please have a try.
Retention =
VAR SelectedDateRange = SELECTEDVALUE('Date'[Date])
VAR Today = TODAY()
VAR DaysBetween = DATEDIFF(EARLIER('Orders'[time_pickup_date]), Today, DAY)
VAR RetainedCustomers =
CALCULATE(
DISTINCTCOUNT('Orders'[customer_id]),
FILTER(
'Orders',
DaysBetween >= 31
&& DaysBetween <= 60
&& 'Orders'[time_pickup_date] >= SelectedDateRange - 30
&& 'Orders'[time_pickup_date] <= SelectedDateRange - 1
)
)
VAR ChurnedCustomers =
CALCULATE(
DISTINCTCOUNT('Orders'[customer_id]),
FILTER(
'Orders',
DaysBetween >= 31
&& DaysBetween <= 60
&& ('Orders'[time_pickup_date] < SelectedDateRange - 30 || 'Orders'[time_pickup_date] > SelectedDateRange - 1)
)
)
RETURN
SWITCH(
TRUE(),
RetainedCustomers = 0 && ChurnedCustomers = 0, BLANK(),
RetainedCustomers = 0, "Churned",
ChurnedCustomers = 0, "Retained",
RetainedCustomers, "Retained",
"Churned"
)
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ Rongtie
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Andrew_na_lang ,
Please have a try.
Retention =
VAR SelectedDateRange = SELECTEDVALUE('Date'[Date])
VAR Today = TODAY()
VAR DaysBetween = DATEDIFF(EARLIER('Orders'[time_pickup_date]), Today, DAY)
VAR RetainedCustomers =
CALCULATE(
DISTINCTCOUNT('Orders'[customer_id]),
FILTER(
'Orders',
DaysBetween >= 31
&& DaysBetween <= 60
&& 'Orders'[time_pickup_date] >= SelectedDateRange - 30
&& 'Orders'[time_pickup_date] <= SelectedDateRange - 1
)
)
VAR ChurnedCustomers =
CALCULATE(
DISTINCTCOUNT('Orders'[customer_id]),
FILTER(
'Orders',
DaysBetween >= 31
&& DaysBetween <= 60
&& ('Orders'[time_pickup_date] < SelectedDateRange - 30 || 'Orders'[time_pickup_date] > SelectedDateRange - 1)
)
)
RETURN
SWITCH(
TRUE(),
RetainedCustomers = 0 && ChurnedCustomers = 0, BLANK(),
RetainedCustomers = 0, "Churned",
ChurnedCustomers = 0, "Retained",
RetainedCustomers, "Retained",
"Churned"
)
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ Rongtie
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.
Check out the May 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 24 | |
| 22 | |
| 21 | |
| 20 | |
| 14 |
| User | Count |
|---|---|
| 59 | |
| 53 | |
| 41 | |
| 31 | |
| 31 |