Forum Discussion
Regulate
8 years agoRegular Visitor
Maximum date difference between consecutive purchases for a customer
Hi! I am having troubles with calculating the maximum difference between two consecutive purchases for each customer. Note that this is not the same as date difference between first and last purc...
- 8 years ago
You can use this column in the Customers Table
Max_diff_between_Purchase = VAR temp = CALCULATETABLE ( VALUES ( Purchase_table[PurchaseDate] ) ) VAR temp1 = ADDCOLUMNS ( temp, "Days", DATEDIFF ( [PurchaseDate], MINX ( FILTER ( temp, [PurchaseDate] > EARLIER ( [PurchaseDate] ) ), [PurchaseDate] ), DAY ) ) RETURN MAXX ( temp1, [Days] ) - 8 years ago
Zubair_Muhammad
8 years agoCommunity Champion
You can use this column in the Customers Table
Max_diff_between_Purchase =
VAR temp =
CALCULATETABLE ( VALUES ( Purchase_table[PurchaseDate] ) )
VAR temp1 =
ADDCOLUMNS (
temp,
"Days", DATEDIFF (
[PurchaseDate],
MINX (
FILTER ( temp, [PurchaseDate] > EARLIER ( [PurchaseDate] ) ),
[PurchaseDate]
),
DAY
)
)
RETURN
MAXX ( temp1, [Days] )- Regulate8 years agoRegular Visitor
Perfect, thank you Zubair! Your column worked like a charm.
I really appreciate the help!
-L
- Zubair_Muhammad8 years agoCommunity Champion