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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
huffd
Frequent Visitor

Churn: Start Date within X days of End Dates

This is a seemingly simple question where I want to know how many IDs have start dates in the current filter context that are within X days (parameter) of any previous endDate.  Sample data are shown below with some annotations.  Both startDate and endDate are connected to the same date table, with startDate being the active relationship.


Assuming the X days parameter is set at 200 days, for each set of rows for a given ID, I would like to identify rows where a StartDate begins within 200 days of a previous EndDate.  These cells are highlighted below:
huffd_0-1670258431326.png

Those highlighted cells have a StartDate that begins within 200 days of a previous EndDate.  

 

With that, I would be able to count the number of returns within X days per ID:

huffd_1-1670258616864.png

or the number of returns within X days by date: 

huffd_2-1670258658745.png

To approach this, I began with a table of Dates[Year] and 'Sample'[ID], so the filter context is the year of startDate.  Then I need to compare a) a list of IDs with startDates in the current filter context to b) a list of IDs where any previous endDate is within X days of the current startDate. Specifically, I want to filter the list in a to only include the IDs that are in b.

 

I wasn't exactly sure how to adjust the filter context for b above (the IDs that have endDates within X days of the current startDate). I obviously need to activate the inactive relationship between 'Dates'[Date] and 'Sample'[EndDate], i.e., 

USERELATIONSHIP(Dates[Date],'Sample'[EndDate]). But I'm not clear how to do it.  I tried doing this inside the measure: 
   
COUNTROWS(
    CALCULATETABLE(
        VALUES( 'Sample'[ID] )
        , FILTER(
            ALL( Dates )
            , Dates[Date] -
                CALCULATE(
                    MIN(Dates[Date])
                    , USERELATIONSHIP(Dates[Date],'Sample'[EndDate])  
                )  
                < __X
        )
    )
)
 
but that doesnt work.  

 

How should i approach this instead? 

 

'Sample':

IDStartDateEndDate
11/1/20186/6/2019
11/1/20206/6/2021
11/1/202212/1/2022
212/1/20173/15/2018
28/15/20183/15/2019
21/1/20206/1/2020
34/15/201712/1/2018
38/15/20191/1/2020
31/1/20216/1/2021
41/1/202112/1/2022
53/15/20187/20/2018
51/1/20197/1/2019
51/1/20211/1/2022
66/1/20176/1/2018
61/1/20226/1/2022
72/1/201910/1/2019
76/1/202211/1/2022
810/1/2019 
911/1/202212/1/2022
1012/1/2022 
2 REPLIES 2
huffd
Frequent Visitor

@amitchandak I made some clarifications in the original post. hopefull it is more clear now. thank you for your reply.

amitchandak
Super User
Super User

@huffd , not very clear, You can get the last end date with new columns

 

maxx(filter(Table, [ID] =earlier([ID])  && [end date] < earlier([end Date]) ), [end date])

 

this can be used to get diff

Power BI DAX- Earlier, I should have known Earlier: https://youtu.be/CVW6YwvHHi8

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.