Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
amitchandak
Super User
Super User

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
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.