Skip to content

Last Purchase Date, and Purchase Amount, by Customer and Product

>> Download the sample (Power BI)

This sample shows the last purchase date and purchase amount of:

(i) A particular customer, and
(ii) A particular product

Amount of Last Purchase =
CALCULATE (
[Total Sales],
LASTNONBLANK ( Calendar_Table[Date], [Total Sales] )
)
Date of Last Purchase =
LASTDATE ( Sales_Table[Date] )
Date of Last Purchase v2 =
LASTNONBLANK ( Calendar_Table[Date], [Total Sales] )
Total Sales =
SUMX ( Sales_Table, Sales_Table[Unit Price] * Sales_Table[Quantity] )
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 )
)