Reputation: 487
I'd like to segment my customers on their purchasing activity (active, sleeping, dead). To do so, I need to find the number of the days between the last purchase date and current context (because the customer can be sleeping in one period and active in another).
So I add the calculated field to the Customers table:
LastPurchaseDate:= LASTDATE(purchases[ClearDate])
and it works fine.
The problem occurs when I try to calculate the days difference between two days:
LastPurchaseDaysAgo:= CALCULATE(1*(TODAY()-[LastPurchaseDate]))
In the result I get the same value everywhere (customers in rows and date hierarchy in columns) and the other fields added to the pivot stop calculating.
Thanks ;)
Upvotes: 0
Views: 585
Reputation: 969
Check that ClearDate is a date not a datetime. If it is a datetime you can transform it in DAX into a date by DATE(YEAR(myTable([ClearDate]),MONTH(myTable([ClearDate]),DAY(myTable([ClearDate]))
. Then you should be able to subtract it from TODAY() to get a numeric value.
Upvotes: 0