Compute year-to-year change in sales, grouped by Year and ProductType.

This query requires inter-aggregate use of information. To compute the change in sales for a given quarter, the total from the prior quarter and the current quarter must be referenced.

RETURN YearOnYearChange AS
SELECT SUM(Amount) AS TotalSales,
  SUM(Amount) -
    YearOnYearChange[Year-1,ProductType].TotalSales AS Change
GROUP BY Year, ProductType


Copyright © Legal Notices