Forum Discussion
finding customer with two different status
- 3 years ago
You need to create a DAX measure or calculated column that will count the number of distinct statuses for each customer in a given month. If the count is greater than 1 and one of the statuses is 'leavers', then you can mark that customer as "Also Leavers".
Also Leavers Column = VAR CurrentCustomer = [Customer ID] VAR CurrentMonth = MONTH([date]) VAR CurrentYear = YEAR([date]) VAR LeaversCount = CALCULATE( COUNTROWS( FILTER( 'TableName', 'TableName'[Customer ID] = CurrentCustomer && MONTH('TableName'[date]) = CurrentMonth && YEAR('TableName'[date]) = CurrentYear && 'TableName'[status] = "leavers" ) ) ) VAR TotalStatus = CALCULATE( COUNTROWS( FILTER( 'TableName', 'TableName'[Customer ID] = CurrentCustomer && MONTH('TableName'[date]) = CurrentMonth && YEAR('TableName'[date]) = CurrentYear ) ) ) RETURN IF(LeaversCount > 0 && TotalStatus > 1, "Also Leavers", BLANK())
You need to create a DAX measure or calculated column that will count the number of distinct statuses for each customer in a given month. If the count is greater than 1 and one of the statuses is 'leavers', then you can mark that customer as "Also Leavers".
Also Leavers Column =
VAR CurrentCustomer = [Customer ID]
VAR CurrentMonth = MONTH([date])
VAR CurrentYear = YEAR([date])
VAR LeaversCount =
CALCULATE(
COUNTROWS(
FILTER(
'TableName',
'TableName'[Customer ID] = CurrentCustomer &&
MONTH('TableName'[date]) = CurrentMonth &&
YEAR('TableName'[date]) = CurrentYear &&
'TableName'[status] = "leavers"
)
)
)
VAR TotalStatus =
CALCULATE(
COUNTROWS(
FILTER(
'TableName',
'TableName'[Customer ID] = CurrentCustomer &&
MONTH('TableName'[date]) = CurrentMonth &&
YEAR('TableName'[date]) = CurrentYear
)
)
)
RETURN
IF(LeaversCount > 0 && TotalStatus > 1, "Also Leavers", BLANK())Hi Amira
Thanks for your reply. Unfortunately I cannot get it to work.
The LeaversCount work
And
The TotalStatus work
But if I have a row where a customer have two in TotalStatus and 1 in LeaversCount it doesn’t say Also Leavers as it should…
Any idea why