Forum Discussion
Anonymous
3 years agoNot applicable
Identify new customers using date differences
I’m currently developing an arrears report based on the following table. I want to look at the new customers that went into arrears this week. So, I only want to include customer C this week (26/06/2...
Martin_D
3 years agoSolution Sage
Hi Anonymous ,
From your sample data and description I assume the following constraints:
- You only want to compare with the directly previous week, not with all previous weeks
- You have weekly data, every 7 days, so you only need to compare with exactly 7 days earlier, not with all dates in the previous week
Then try the following:
Count of new customers =
VAR _selectedWeek = MAX ( 'Table'[Date] )
VAR _previousWeek = _selectedWeek - 7
VAR _customersSelectedWeek =
CALCULATETABLE (
VALUES ( 'Table'[Customer] ),
'Table'[Date] = _selectedWeek
)
VAR _customersPreviousWeek =
CALCULATETABLE (
VALUES ( 'Table'[Customer] ),
'Table'[Date] =_previousWeek
)
VAR _newCustomers = EXCEPT ( _customersSelectedWeek, _customersPreviousWeek )
VAR _countOfNewCustomers = COUNTAX ( _newCustomers, [Customer] )
RETURN
_countOfNewCustomers
Anonymous
3 years agoNot applicable
This works great. Thank you Martin_D