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

lost customers

how to identify lost customer?

lost customers on given date are those customers who never placed order between past 90 days and future 90 days on given date

 

example lost customers on 01-June-2001 should be those customers who never placed orders between 01st march 2001 and 30-sept-2001

 

below is the sample data

 

powerbiexpert22_0-1710636929762.png

 

 

 

 

powerbiexpert22_2-1710636973693.png

powerbiexpert22_3-1710637009034.png

 

 

 

 

 

 

 

 

 

 

 

 

2 ACCEPTED SOLUTIONS
talespin
Solution Sage
Solution Sage

hi @powerbiexpert22 

 

I used Contoso Sales

 

This measure checks for Sales +/- 90 days from 2012-06-01, since I did not have recent data. Please change it to Today() or as per your need.

 

Sales Plus Minus 90 Days =
VAR _StartDate = DATE(2012,6,1) - 90
VAR _EndDate = DATE(2012,6,1) + 90
VAR _SalesCount = CALCULATE( COUNTROWS(Orders), 'Date'[Date] >= _StartDate && 'Date'[Date] <= _EndDate)

RETURN IF(_SalesCount = 0, "Lost Customer", BLANK())

View solution in original post

v-xuxinyi-msft
Community Support
Community Support

Hi @powerbiexpert22 

 

First of all, thanks to @talespin for your timely and effective response.

 

Here are my additions.

 

My slicer table:

vxuxinyimsft_1-1710750114205.png

 

You can create a measure as follows.

Measure = 
VAR _selectedvalue = SELECTEDVALUE('Date'[Date])
VAR _l90 = EOMONTH(_selectedvalue, -4) + 1
VAR _f90 = EOMONTH(_selectedvalue, +3)
VAR _cid = CALCULATE(MAX('order'[customerid]), FILTER('order', [orderdate] >= _l90 && [orderdate] <= _f90))
VAR _cname = CALCULATE(MAX(customer[name]), FILTER('customer', [customerid] = _cid))
RETURN
IF(MAX(customer[name]) = _cname, BLANK(), "lost customer")

 

Result:

vxuxinyimsft_0-1710750082896.png

 

If this is not the result you want, please show the result you want in excel format so we can help you better.

 

Best Regards,
Yulia Xu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-xuxinyi-msft
Community Support
Community Support

Hi @powerbiexpert22 

 

First of all, thanks to @talespin for your timely and effective response.

 

Here are my additions.

 

My slicer table:

vxuxinyimsft_1-1710750114205.png

 

You can create a measure as follows.

Measure = 
VAR _selectedvalue = SELECTEDVALUE('Date'[Date])
VAR _l90 = EOMONTH(_selectedvalue, -4) + 1
VAR _f90 = EOMONTH(_selectedvalue, +3)
VAR _cid = CALCULATE(MAX('order'[customerid]), FILTER('order', [orderdate] >= _l90 && [orderdate] <= _f90))
VAR _cname = CALCULATE(MAX(customer[name]), FILTER('customer', [customerid] = _cid))
RETURN
IF(MAX(customer[name]) = _cname, BLANK(), "lost customer")

 

Result:

vxuxinyimsft_0-1710750082896.png

 

If this is not the result you want, please show the result you want in excel format so we can help you better.

 

Best Regards,
Yulia Xu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

talespin
Solution Sage
Solution Sage

hi @powerbiexpert22 

 

I used Contoso Sales

 

This measure checks for Sales +/- 90 days from 2012-06-01, since I did not have recent data. Please change it to Today() or as per your need.

 

Sales Plus Minus 90 Days =
VAR _StartDate = DATE(2012,6,1) - 90
VAR _EndDate = DATE(2012,6,1) + 90
VAR _SalesCount = CALCULATE( COUNTROWS(Orders), 'Date'[Date] >= _StartDate && 'Date'[Date] <= _EndDate)

RETURN IF(_SalesCount = 0, "Lost Customer", 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.