Skip to content

When a Customer might next buy, based on Historical Purchase Pattern

>> Download the sample (Power BI)

This sample shows when a customer might buy next, based on the difference between the number of days since their last purchase and the average number of days between their past purchases.

Average Days between Purchases =
VAR FirstPurchaseDate =
FIRSTDATE ( Sales_Table[Date] )
VAR LastPurchsaeDate =
LASTDATE ( Sales_Table[Date] )
VAR TotalTransactingDays =
DISTINCTCOUNT ( Sales_Table[Date] )
RETURN
DIVIDE ( LastPurchsaeDate - FirstPurchaseDate, TotalTransactingDays - 1, 0 )
Date of First Purchase =
FIRSTDATE ( Sales_Table[Date] )
Date of Last Purchase =
LASTDATE ( Sales_Table[Date] )
Days above average =
[Days Since Last Purchase] - [Average Days between Purchases]
Days Since Last Purchase =
IF (
ISBLANK ( [Date of Last Purchase] ),
BLANK (),
VALUE ( [Last Purchase Date for All Sales] - [Date of Last Purchase] )
)
Last Purchase Date for All Sales =
MAXX ( ALL ( Sales_Table[Date] ), Sales_Table[Date] )
No. of Distinct Customers =
DISTINCTCOUNT ( Sales_Table[Customer] )
Total Sales =
SUMX ( Sales_Table, Sales_Table[Unit Price] * Sales_Table[Quantity] )
Total Transacting Days =
DISTINCTCOUNT ( Sales_Table[Date] )
Calendar_Table =
GENERATE (
CALENDAR ( DATE ( 2017, 1, 1 ), DATE ( 2019, 12, 31 ) ),
VAR currentDay = [Date]
VAR Day =
DAY ( currentDay )
VAR Month =
MONTH ( currentDay )
VAR Year =
YEAR ( currentDay )
RETURN
ROW ( "Day", day, "Month", month, "Year", year )
)