Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
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.
I hope that makes sense!
Simulated data sources:
Result :
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] )
)
User | Count |
---|---|
53 | |
28 | |
19 | |
18 | |
14 |
User | Count |
---|---|
92 | |
86 | |
39 | |
23 | |
22 |