Hello @AliB,
To find the names of the “Lost Customers”. Below is the measure provided for the reference -
Lost Customers - Names =
VAR LastDateLost =
CALCULATE (
MAX ( Dates[Date] ),
ALLSELECTED ( Dates )
)
VAR CustomersWithLostDate =
CALCULATETABLE (
ADDCOLUMNS (
VALUES ( Customers[Customer] ),
"@LostCustomerDate", [Date Lost Customer]
),
ALLSELECTED ( Customers ),
Dates[Date] <= LastDateLost
)
VAR LostCustomers =
FILTER (
CustomersWithLostDate,
[@LostCustomerDate]
IN VALUES ( Dates[Date] )
)
VAR NoOfLostCustomers =
COUNTROWS ( LostCustomers )
VAR NamesOfCustomersLost =
CONCATENATEX(
LostCustomers ,
Customers[Customer] ,
", " )
VAR Results =
IF( HASONEVALUE( Dates[MonthInCalendar] ) ,
NamesOfCustomersLost ,
BLANK() )
RETURN
Results
And then to calculate the “Lost Customers Sales” below is the measure provided for the reference -
Sales Lost Customers =
VAR LastDateLost =
CALCULATE (
MAX ( Dates[Date] ),
ALLSELECTED ( Dates )
)
VAR CustomersWithLostDate =
CALCULATETABLE (
ADDCOLUMNS (
VALUES ( SalesData[Group] ),
"@LostCustomerDate", [Date Lost Customer]
),
ALLSELECTED ( Customers ),
Dates[Date] <= LastDateLost
)
VAR LostCustomers =
FILTER (
CustomersWithLostDate,
[@LostCustomerDate]
IN VALUES ( Dates[Date] )
)
VAR Previous12Months =
DATESINPERIOD (
Dates[Date],
EOMONTH ( MAX ( Dates[Date] ), -3 ),
-12,
MONTH
)
VAR Result =
CALCULATE (
[Total Sales],
Previous12Months,
KEEPFILTERS ( LostCustomers )
)
RETURN
Result
Now, after writing these 2 measures you’ll be able to see the results at a consolidated as well as at an individual level i.e. The Names of the Customers that are lost as well as the Lost Sales Value against those Customers. Below is the screenshot of the final results provided for the reference -
I’m also attaching the working of the PBIX file for the reference purposes.
Hoping you find this useful and meets your requirements that you’ve been looking for.
Thanks and Warm Regards,
Harsh
Customer Attrition Test - Harsh v2.pbix (388.3 KB)