// QueryAndChart — month-over-month change and 3-month moving average measures
// Paste into Power BI Desktop: Modeling > New measure, one measure at a time.
// Tables: Sales (Month, Category, Units, Revenue), Calendar (Date).
// Relationship: Calendar[Date] (one) to Sales[Month] (many), single direction.
Total Sales = SUM ( Sales[Revenue] )

Sales PM =
CALCULATE (
    [Total Sales],
    PREVIOUSMONTH ( Calendar[Date] )
)

MoM % Change =
DIVIDE (
    [Total Sales] - [Sales PM],
    [Sales PM]
)

3-Month Moving Average =
AVERAGEX (
    DATESINPERIOD (
        Calendar[Date],
        MAX ( Calendar[Date] ),
        -3,
        MONTH
    ),
    [Total Sales]
)
