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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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