I'm tring to sum up sales figures by month (there are several entries for each month) using a crosstab query. That part is working fine - I get the months, and the total sales from all customers for that month.
What I also want to do is calculate last year's figures in the same crosstab query. Or calculate last years figures in a different query, then combine the two in a third query.
I'm having trouble doing either. Any solutions?
If this helps, below is the sql of the current query (that works, but only for the current year):
PARAMETERS [Forms]![SalesBySlsmDialog]![BeginYear] Long, [Forms]![SalesBySlsmDialog]![Month] Long, [Forms]![SalesBySlsmDialog]![Salesman] Long, [Forms]![SalesBySlsmDialog]![MfgCombo] Long;
TRANSFORM Sum([All-Mfgs_All-Reps Query].Amount) AS [The Value]
SELECT [All-Mfgs_All-Reps Query].Month, [All-Mfgs_All-Reps Query].MonthID
FROM [All-Mfgs_All-Reps Query]
WHERE ((([All-Mfgs_All-Reps Query].MonthID)<=[Forms]![SalesBySlsmDialog]![Month]) AND (([All-Mfgs_All-Reps Query].Year)=[Forms]![SalesBySlsmDialog]![BeginYear]) AND (([All-Mfgs_All-Reps Query].ImployeeID)=[Forms]![SalesBySlsmDialog]![Salesman]) AND (([All-Mfgs_All-Reps Query].DealerID)=[Forms]![SalesBySlsmDialog]![MfgCombo]))
GROUP BY [All-Mfgs_All-Reps Query].Month, [All-Mfgs_All-Reps Query].MonthID
ORDER BY [All-Mfgs_All-Reps Query].MonthID
PIVOT [All-Mfgs_All-Reps Query].EmployeeLastName;
What I also want to do is calculate last year's figures in the same crosstab query. Or calculate last years figures in a different query, then combine the two in a third query.
I'm having trouble doing either. Any solutions?
If this helps, below is the sql of the current query (that works, but only for the current year):
PARAMETERS [Forms]![SalesBySlsmDialog]![BeginYear] Long, [Forms]![SalesBySlsmDialog]![Month] Long, [Forms]![SalesBySlsmDialog]![Salesman] Long, [Forms]![SalesBySlsmDialog]![MfgCombo] Long;
TRANSFORM Sum([All-Mfgs_All-Reps Query].Amount) AS [The Value]
SELECT [All-Mfgs_All-Reps Query].Month, [All-Mfgs_All-Reps Query].MonthID
FROM [All-Mfgs_All-Reps Query]
WHERE ((([All-Mfgs_All-Reps Query].MonthID)<=[Forms]![SalesBySlsmDialog]![Month]) AND (([All-Mfgs_All-Reps Query].Year)=[Forms]![SalesBySlsmDialog]![BeginYear]) AND (([All-Mfgs_All-Reps Query].ImployeeID)=[Forms]![SalesBySlsmDialog]![Salesman]) AND (([All-Mfgs_All-Reps Query].DealerID)=[Forms]![SalesBySlsmDialog]![MfgCombo]))
GROUP BY [All-Mfgs_All-Reps Query].Month, [All-Mfgs_All-Reps Query].MonthID
ORDER BY [All-Mfgs_All-Reps Query].MonthID
PIVOT [All-Mfgs_All-Reps Query].EmployeeLastName;