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

Average lost sales of lost customers

Hi there,

 

I have raw data of sales by customer for the past 3 years, and I am trying to

 

1) highlight lost customers, defined by: Customer that has not bought anything for the past 12 months. 

2) highlight lost sales of above customers, defined by: Average monthly sales over the 6 months that precedes the past 12 months of no sales. 

 

Are these formulae correct?

Thank you so much.

 

Lost Customers =
VAR CustomersPurchased= CALCULATETABLE(VALUES('Raw Data'[Client ID (#)]),

FILTER(ALL('Calendar'),'Calendar'[Date] > MIN('Calendar'[Date]) - 720 && 'Calendar'[Date] < MIN('Calendar'[Date]) - 360))

 

VAR PriorCustomers=CALCULATETABLE(VALUES('Raw Data'[Client ID (#)]), FILTER(ALL('Calendar'), 'Calendar'[Date] > MIN('Calendar'[Date]) - 360 && 'Calendar'[Date] < MIN('Calendar'[Date])))
RETURN
COUNTROWS(EXCEPT(CustomersPurchased, PriorCustomers)) * -1

 

Average Lost Sales Value =
VAR CustomersPurchased= CALCULATETABLE(VALUES('Raw Data'[Client ID (#)]),FILTER(ALL('Calendar'), 'Calendar'[Date] > MIN('Calendar'[Date]) - 720 && 'Calendar'[Date] < MIN('Calendar'[Date]) - 360 ))
VAR PriorCustomers= CALCULATETABLE(VALUES('Raw Data'[Client ID (#)]),FILTER(ALL('Calendar'), 'Calendar'[Date] > MIN('Calendar'[Date]) - 360 && 'Calendar'[Date] < MIN('Calendar'[Date])))
RETURN
CALCULATE(
CALCULATE([Average Monthly Sales],
DATESBETWEEN('Calendar'[Date], MIN('Calendar'[Date]) - 720, MIN('Calendar'[Date])-360 )),
EXCEPT(CustomersPurchased, PriorCustomers)) * -1

 

Ave Monthly Sales = DIVIDE(CALCULATE(SUMX('Raw Data','Raw Data'[USD Total]),DATESINPERIOD('Calendar'[Date],MAX('Calendar'[Date]),-6,MONTH)),6,BLANK())

2 REPLIES 2
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @appley922 ,

Have you solved your problem?

If you have solved, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

If you still need help, please feel free to ask.

Best Regards,

Cherry

 

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @appley922 ,

 

It seems that your formulas have no syntax error. 

 

However, to check if it is correct, I'm afraid that you'd better to have a test with these formulas.

 

If you still need help, please share your data sample and your desired output so that we could help further on it.

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.