Forum Discussion
Sumx and datesbetween two date columns
- 6 years ago
Hi AlexanderBP,
Please try this column formula, it results in the following table based on your sample data.
20DaysPurchases = var custId = [Customer id] var firstPurchaseDate = CALCULATE(MIN([Customer Added Date]), filter(ALL('Table'), 'Table'[Customer id] = custId))+20 return CALCULATE(SUM([Turnover]), FILTER(ALL('Table'), 'Table'[Purchase Date] <= firstPurchaseDate && 'Table'[Customer id] = custId))Hope this Helps,
Richard
Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up! - 6 years ago
Hi AlexanderBP ,
The below column works in your scenario, too. The calculation logic is similar to that of richbenmintz.
And if you create it as a measure, it also works.
20DaysPurchases = VAR FirstPurchase = CALCULATE ( MIN ( 'Table'[Purchase Date] ), ALLEXCEPT ( 'Table', 'Table'[Customer id] ) ) RETURN CALCULATE ( SUM ( 'Table'[Turnover] ), FILTER ( ALLEXCEPT ( 'Table', 'Table'[Customer id] ), 'Table'[Purchase Date] <= FirstPurchase + 20 ) )You can check more details from here.
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi AlexanderBP ,
The below column works in your scenario, too. The calculation logic is similar to that of richbenmintz.
And if you create it as a measure, it also works.
20DaysPurchases =
VAR FirstPurchase =
CALCULATE (
MIN ( 'Table'[Purchase Date] ),
ALLEXCEPT ( 'Table', 'Table'[Customer id] )
)
RETURN
CALCULATE (
SUM ( 'Table'[Turnover] ),
FILTER (
ALLEXCEPT ( 'Table', 'Table'[Customer id] ),
'Table'[Purchase Date] <= FirstPurchase + 20
)
)
You can check more details from here.
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.