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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.