Two tables. Sales_Fact & DateKey. Joined on date.
DateKey table dynamic based on Sales:
DateKey = CALENDAR(MIN(Sales_Fact[Date]),MAX(Sales_Fact[Date]))
Sales Table has the following structure.
Customer PurchaseDate FirstTimePurchaseDate Amount
A 2018/04/11 2018/02/26 500
b 2018/04/11 2018/03/01 300
c 2018/04/11 2018/04/11 400
A 2018/04/12 2018/02/26 100
b 2018/04/12 2018/03/01 200
c 2018/04/12 2018/04/11 400
I want to calculate total purchase amount per customer 31 days after they made their first purchase. The Sales table has continuous dates for the last 2 year, no 'purchase date' missing.
Following measure returns the 'DATEADD' expects a contiguous selection... error
First 31 days = CALCULATE(SUM(Sales_Fact[Amount]),DATESBETWEEN(Sales_Fact[PurchaseDate],MIN(Sales_Fact[FirstTimePurchaseDate]),DATEADD(Sales_Fact[PurchaseDate],31,DAY)))
How should the DAX expression be written in order for this measure to work?
Thanks