I tried the below code but got a lot of errorsYes, but you should probably UNION then cross-tab.
TRANSFORM Sum([Stock on Hand Qry - Manufactured].Qty) AS SumOfQty
SELECT [Stock on Hand Qry - Manufactured].Product, Sum([Stock on Hand Qry - Manufactured].Qty) AS [Total Of Qty]
FROM [Stock on Hand Qry - Manufactured]
GROUP BY [Stock on Hand Qry - Manufactured].Product
PIVOT [Stock on Hand Qry - Manufactured].[Stock Location]
Union
TRANSFORM Sum([Stock on Hand Qry - Manufactured].Volume) AS SumOfVolume
SELECT [Stock on Hand Qry - Manufactured].Product, Sum([Stock on Hand Qry - Manufactured].Volume) AS [Total Of Volume]
FROM [Stock on Hand Qry - Manufactured]
GROUP BY [Stock on Hand Qry - Manufactured].Product
PIVOT [Stock on Hand Qry - Manufactured].[Stock Location];
TRANSFORM Sum([Stock on Hand Qry - Manufactured].Qty) AS SumOfQty
SELECT [Stock on Hand Qry - Manufactured].Product, Sum([Stock on Hand Qry - Manufactured].Qty) AS [Total Of Qty],"" As [Total Of Volume]
FROM [Stock on Hand Qry - Manufactured]
GROUP BY [Stock on Hand Qry - Manufactured].Product
PIVOT [Stock on Hand Qry - Manufactured].[Stock Location]
Union
TRANSFORM Sum([Stock on Hand Qry - Manufactured].Volume) AS SumOfVolume
SELECT [Stock on Hand Qry - Manufactured].Product,"" As [Total Of Qty], Sum([Stock on Hand Qry - Manufactured].Volume) AS [Total Of Volume]
FROM [Stock on Hand Qry - Manufactured]
GROUP BY [Stock on Hand Qry - Manufactured].Product
PIVOT [Stock on Hand Qry - Manufactured].[Stock Location];
Yes I need the Qty and the Volume in the same rowDon't you want the Qty and Volume to be on same row for each Product? Review http://allenbrowne.com/ser-67.html#MultipleValues
Method not demonstrated in that article would involve a UNION first then CROSSTAB.
SELECT ID, Product, Location, Qty AS Data, "Qty" AS Src FROM table
UNION SELECT ID, Product, Location, Volume, "Vol" FROM table;
TRANSFORM Sum(Data) AS SumData
SELECT Product
FROM Query1
GROUP BY Product
PIVOT Src & Location;
However, UNION might perform slowly with large datasets.
If you need more assistance, show sample data as table in post or attach file.
When I do the 2 cross tab queries and the a union on the 2, I still get the same problemDon't you want the Qty and Volume to be on same row for each Product? Review http://allenbrowne.com/ser-67.html#MultipleValues
Method not demonstrated in that article would involve a UNION first then CROSSTAB.
SELECT ID, Product, Location, Qty AS Data, "Qty" AS Src FROM table
UNION SELECT ID, Product, Location, Volume, "Vol" FROM table;
TRANSFORM Sum(Data) AS SumData
SELECT Product
FROM Query1
GROUP BY Product
PIVOT Src & Location;
However, UNION might perform slowly with large datasets.
If you need more assistance, show sample data as table in post or attach file.
TRANSFORM Sum([Stock on Hand Qry - Manufactured].Qty) AS SumOfQty
SELECT [Stock on Hand Qry - Manufactured].Product, Sum([Stock on Hand Qry - Manufactured].Qty),"" As Sum([Stock on Hand Qry - Manufactured].Volume)
FROM [Stock on Hand Qry - Manufactured]
GROUP BY [Stock on Hand Qry - Manufactured].Product
PIVOT [Stock on Hand Qry - Manufactured].[Stock Location]
Union
TRANSFORM Sum([Stock on Hand Qry - Manufactured].Volume) AS SumOfVolume
SELECT [Stock on Hand Qry - Manufactured].Product, Sum([Stock on Hand Qry - Manufactured].Volume),"" As Sum([Stock on Hand Qry - Manufactured].Qty)
FROM [Stock on Hand Qry - Manufactured]
GROUP BY [Stock on Hand Qry - Manufactured].Product
PIVOT [Stock on Hand Qry - Manufactured].[Stock Location];
Yeh, still not getting itIt works for me.
You have not done UNION and CROSSTAB according to my example. There is only one CROSSTAB in my example when UNION is used.
By joining and not doing a union, would you still get the extra headings should the crosstab change?Allen Brown's example does not use UNION. Mine does. Gismo said they were trying UNION approach but what they show is not following my example.
Allen's method uses a helper table and one CROSSTAB.
If you want to build two CROSSTABs then you would JOIN them, not UNION.