I have following Data Structure
Date | Category | Sales Amount
----------------------------------------------------
01-Sep-2016 | Food | 100
02-Sep-2016 | Food | 120
03-Sep-2016 | Food | 130
01-Sep-2016 | Electricity | 180
02-Sep-2016 | Electricity | 60
01-Sep-2016 | Perfumes | 80
02-Sep-2016 | Perfumes | 40
I want to calculate the Two Week Sales for Each Category, I might add another column like Territory as well in the future. I used following Formula which worked fine if I only select Date but Does Not Work if I select Category.
SalesTwoWeeksAgo =
CALCULATE (
SUM ( 'Table'[SalesAmount] ),
FILTER (
ALL ( 'Table' ),
COUNTROWS (
FILTER (
'Table',
EARLIER ( 'Table'[Date] ) = DATEADD ( 'Table'[Date], -14, DAY )
)
)
)
)
The Above Formula was contributed by alejandro zuleta and link is