I am using this T-SQL referring to AdventureWorks2008R2:
SELECT DATENAME(yy, sh.OrderDate) AS Year, DATENAME(mm, sh.OrderDate) AS Month, CONVERT(VARCHAR, CAST(SUM(sd.LineTotal) AS Money), 1) AS TotalMonthSales FROM Sales.Customer AS sc INNER JOIN Sales.SalesOrderHeader AS sh ON sc.CustomerID = sh.CustomerID INNER JOIN Sales.SalesOrderDetail AS sd ON sh.SalesOrderID = sd.SalesOrderID GROUP BY DATENAME(yy, sh.OrderDate), DATENAME(mm, sh.OrderDate) ORDER BY Year DESC, Month DESC
I am having a few problems at this stage getting what I would like in a matrix in VS2008. I did this before through dragging and dropping, but for some reason can't repeat it again...
I dragged from the DataSet the Year and Month to theRows part of the matrix and the TotalMonthSales to theData part. All is well with this but I am trying to get subtotals of each year as well as the total off all the years put together (i.e. 2008-2005). In the Tablix Data partAddTotal is blanked out in the TotalMonthSales area.
In my previous test version all the formulas in the Data part showed a Sum, but as mentioned I did all this by dragging and dropping and am not sure how to repeat this now. Also, theYear and Month are showing in a different (reverse) order to the above T-SQL in SSRS.
Any ideas?