Multiple column transpose query

Mariyka1

New Member
Joined
Nov 1, 2016
Messages
44
Hello - I'm trying to transpose multiple columns into two columns in access (second column being the title) access data currently looks like this

Period01 Period02 Period03
120 200 500
110 300 600
200 400 700

I want it to look like this:
January 120
January 110
January 200
February 200
February 300
February 400
ETC

I created this query but I'm getting an error message o incorrect spelling/punctuation



SELECT [Period01] as Month, [January] as value
FROM Summary_ALL
WHERE [Period01] IS NOT NULL


UNION ALL


SELECT [Period02] as Month, [February] as value
FROM Summary_ALL
WHERE [Period02] IS NOT NULL


UNION ALL


SELECT [Period03] as Month, [March] as value
FROM Summary_ALL
WHERE [Period03] IS NOT NULL


UNION ALL


SELECT [Period04] as Month, [April] as value
FROM Summary_ALL
WHERE [Period04] IS NOT NULL


Any insight is appreciated!
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
A few issues.
1. Do not use reserved words like "value" as the name of variables or aliases. This is what is causing your error.
2. If you want to hard-code months, include them in quotes or double-quotes. When you put them in square brackets, it is looking for a field name or input parameter.

So, the first one should look something like:
Code:
SELECT "January" AS Month_Name, [Period01] AS Month_Value
FROM Summary_ALL
[COLOR=#333333]WHERE [Period01] Is Not Null[/COLOR]
Repeat the same logic for the rest of the subqueries in your Union Query.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,814
Messages
6,181,128
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top