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
Khalidc
Frequent Visitor

Lost customers

Hi 

I try to calculate the lost customers over time in a specific week. I feel like I am almost there but cannot get it to work. I am for sure overseeing something in the measure, hopefully you can help.

The assumption used it that all customers who have a last sale older than 12 weeks should be considered lost. The measure should be able to present the lost customer in a stack column chart but also show which customers are lost in a matrix table when selecting the period in the chart.

 

# lost customers week = 
var SelectedWeek = SELECTEDVALUE('FS_Vertaling weken naar perioden'[Index - week])

var allcustomers = values(FS_Omzet_uren_all[Groepnaam]) --take all customers
var customerinactiveperiod = CALCULATETABLE( values(FS_Omzet_uren_all[Groepnaam]), --select all customers who match below filter
filter( all( 'FS_Vertaling weken naar perioden'), --remove all date filters
'FS_Vertaling weken naar perioden'[Index - week] > SelectedWeek-12 &&
'FS_Vertaling weken naar perioden'[Index - week] < SelectedWeek)) --take all customers with sales in the last 12 weeks

return

COUNTROWS(
EXCEPT(allcustomers,customerinactiveperiod)) --take all customers and remove all active customers (customers in active period)

This is what I get:

Khalidc_2-1647010520434.png

This is what I would expect:

Khalidc_1-1647010366618.png

 

2 REPLIES 2

Unfortunately Amit, I tried it but unfortunately doesn't seem te work.

 

I am working with non-date periods. I have indexed the weeks, which start at week 1 in 2019 (index 1) and counting until today.

 

The rolling 3 and rolling 9 before 3 seem to give the correct result. However the Lost customer in period remain blank everywhere.

 

I copied the measures used below. Groepnaam is the customer name which is in the sales transaction table (hence customer/groepnaam is not unique in the table).

 

Hopefully you see what is missing.

 

#Rolling 3 = 

var MaxIndex = SELECTEDVALUE('FS_Vertaling weken naar perioden'[Index - week])
var MinIndex = MaxIndex - 12

return

calculate('03 FS measures'[Omzet totaal],
Filter (all('FS_Vertaling weken naar perioden'),
'FS_Vertaling weken naar perioden'[Index - week] <= MaxIndex &&
'FS_Vertaling weken naar perioden'[Index - week] > MinIndex))

#Rolling 9 before three = 
var MaxIndex = SELECTEDVALUE('FS_Vertaling weken naar perioden'[Index - week])-12
var MinIndex = MaxIndex - 52

return

calculate('03 FS measures'[Omzet totaal],
Filter (all('FS_Vertaling weken naar perioden'),
'FS_Vertaling weken naar perioden'[Index - week] <= MaxIndex &&
'FS_Vertaling weken naar perioden'[Index - week] > MinIndex))
#Lost Customer This Period = 
Sumx(VALUES(FS_Omzet_uren_all[Groepnaam]),
if(ISBLANK([#Rolling 3]) && not(ISBLANK([#Rolling 9 before three])) , 1,BLANK()))
 

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.

Top Solution Authors