Solved convert Row Fields From horizontall To vertical

FahadTiger

Member
Local time
Today, 10:57
Joined
Jun 20, 2021
Messages
120
Hi EXPERT..
its possible in Excel..but I have no idea how can do it in access
I have this table
1646937741270.png

and I want it like this
1646937822235.png

im thinking about crosstab.. but no have idea how to do it
thanks for all
 
Looking at your expected results closer, a crosstab will not work--you can't invert columns and rows with it. So, while you can achieve your horizontal values (Tomatto, Orange, Apple) you cannot get all 3 fields you want verticaly (Quantity, Price, Total). You can only get 1 of those values in there.

What you could do is 3 crosstabs--one for each vertical field. Then UNION those 3 queries together.
 
First, build UNION query. Must type or copy/paste into SQL view window of query builder.

SELECT ID, ItemName, Total AS Data, "Total" AS Cat FROM Table1
UNION SELECT ID, ItemName, Price, "Price" FROM Table1
UNION SELECT ID, ItemName, Quantity, "Quantity" FROM Table1;

Now, build CROSSTAB using the UNION query as source.

TRANSFORM Sum(Query1.Data) AS SumOfData
SELECT Query1.Cat
FROM Query1
GROUP BY Query1.Cat
PIVOT Query1.ItemName;
 
First, build UNION query. Must type or copy/paste into SQL view window of query builder.

SELECT ID, ItemName, Total AS Data, "Total" AS Cat FROM Table1
UNION SELECT ID, ItemName, Price, "Price" FROM Table1
UNION SELECT ID, ItemName, Quantity, "Quantity" FROM Table1;

Now, build CROSSTAB using the UNION query as source.

TRANSFORM Sum(Query1.Data) AS SumOfData
SELECT Query1.Cat
FROM Query1
GROUP BY Query1.Cat
PIVOT Query1.ItemName;
its perfect...thank you June7
 

Users who are viewing this thread

Back
Top Bottom