This is a straightforward Measure. Showing the last purchase date for every product. Only the Rows that have a valid date is displayed by default (this setting can be changed):
Last Specific Product Purchase Date =
var _LatestFactDateKey =
MAX(FactSales[OrderDateKey])
var _LatestDateFromFact =
CALCULATE(MAX(DimDate[DailyDate]),
FILTER(ALLSELECTED(FactSales),
FactSales[OrderDateKey] = _LatestFactDateKey
)
)
return
_LatestDateFromFact

Get the last purchase date regardless of which product was bought. Note how dates are still there even when there are no row counts. This is the CORRECT code.
Absolute Last Purchase Date From All Buyers for Every Row =
var _LatestFactDateKey =
CALCULATE(MAX(FactSales[OrderDateKey]),
ALLSELECTED(FactSales)
)
var _LatestDateFromFact =
CALCULATE(MAX(DimDate[DailyDate]),
FILTER(ALLSELECTED(FactSales),
FactSales[OrderDateKey] = _LatestFactDateKey
)
)
return
_LatestDateFromFact

The below is INCORRECT when FILTERing by columns as highlighted in RED. The CROSSFILTER is used else it gets the end date from the Date table rather than the Fact table
Absolute Last Purchase Date From All Buyers (INCORRECT) =
var _LatestFactDateKey =
CALCULATE(MAX(FactSales[OrderDateKey]),
ALLSELECTED(FactSales[OrderDateKey])
)
var _LatestDateFromFact =
CALCULATE(MAX(DimDate[DailyDate]),
FILTER(ALLSELECTED(FactSales[OrderDateKey]),
FactSales[OrderDateKey] = _LatestFactDateKey
)
, CROSSFILTER ( FactSales[OrderDateKey], DimDate[DateKey], BOTH )
)
return
_LatestDateFromFact

If you only want to show the dates that match the last dates, then use the code below. Note that in the first CALCULATE I am filtering the entire Fact table whereas in the second CALCULATE I am including the column. This inclusion of the column tells Power BI to only DimDate and only filter the matching dates. Also, the CROSSFILTER is used again else it will retrieve the end date from the Date table rather than the Fact table
Matching Only - Absolute Last Purchase Date From All Buyers =
var _LatestFactDateKey =
CALCULATE(MAX(FactSales[OrderDateKey]),
ALLSELECTED(FactSales)
)
var _LatestDateFromFact =
CALCULATE(MAX(DimDate[DailyDate]),
FILTER(ALLSELECTED(FactSales[OrderDateKey]),
FactSales[OrderDateKey] = _LatestFactDateKey
)
, CROSSFILTER ( FactSales[OrderDateKey], DimDate[DateKey], BOTH )
)
return
_LatestDateFromFact

The model




















