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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
thartman
Regular Visitor

Accumulative Customer Count by Date

Hello,

I have a table that has a Customer AccountID, Date Installed, and Date Cancelled. 

I'm looking to create a count of how many customers were active in a given date range. My data source only gives me the current status of the customer. So historical reporting is not there. 

I'm trying to create a measure that counts an account as "Active" during a date range, if the cancel date is blank, or AFTER the date.

For example if a customer signed up in January, and cancelled in March. I want to count them as "Active" in January, February, and then cancelled in March. 
For example, the accounts below that don't have a cancel date are "Active". The last account on the record should be counted as "Active" until May 14, 2020 (even though the current status is "cancelled" the account WAS active prior to that cancel date. 

thartman_2-1614370152385.png

I hope that makes sense!

 

1 REPLY 1
jameszhang0805
Resolver IV
Resolver IV

Simulated data sources:

jameszhang0805_0-1614413571283.png

Result :

jameszhang0805_1-1614413662307.png

DAX Code:

#Customer = 
CALCULATE(
    VAR _MINDate =
        MIN ( 'Date'[Date] )
    VAR _MAXDate =
        MAX ( 'Date'[Date] )
    VAR _DateRange =
        DATESBETWEEN ( 'Date'[Date], _MINDate, _MAXDate )
    VAR _Customer =
            CALCULATE (
                DISTINCTCOUNT ( 'Table'[AccountID] ),
                _DateRange,
                'Table'[CancelDate-Recent] = BLANK ()
                    || 'Table'[CancelDate-Recent] >= _MAXDate
            )
    RETURN _Customer
    , DATESYTD( 'Date'[Date] ) 
)

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors