Power BI DAX Calculating Last week Sales for All the Filter Options
<p>I have following Data Structure</p>

<pre><code>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
</code></pre>

<p>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. </p>

<pre><code>SalesTwoWeeksAgo =
CALCULATE (
    SUM ( 'Table'[SalesAmount] ),
    FILTER (
        ALL ( 'Table' ),
        COUNTROWS (
            FILTER (
                'Table',
                EARLIER ( 'Table'[Date] ) = DATEADD ( 'Table'[Date], -14, DAY )
            )
        )
    )
)
</code></pre>

<p>The Above Formula was contributed by alejandro zuleta and link is </p>

<p><a href="https://stackoverflow.com/questions/39716057/power-bi-getting-2-week-back-same-day-value">Power BI getting 2 week back same day value</a></p>