Solved

ms access transpose columns and values to rows

Posted on 2014-12-31
3
1,369 Views
Last Modified: 2014-12-31
Hello!

I have a query that has the following structure:
Date           Dim01   Dim02    Dim03    Dim04
12/31/14    0.123     1.234      0.567      2.987
01/05/15    0.126     1.287      0.611      2.888

Is it possible to make a crosstab query (or any type) to get an output like this?
Date           Dim        Value
12/31/14    Dim01    0.123
12/31/14    Dim02    1.234
12/31/14    Dim03    0.567
12/31/14    Dim04    2.987
01/05/15    Dim01    0.126
01/05/15    Dim02    1.287
01/05/15    Dim03    0.611
01/05/15    Dim04    2.888

The ultimate goal is to produce a report and graph that will show the variation for an individual Dimension over time.

Any and all help and suggestions are appreciated.  Thanks for your time and have a great new year!
0
Comment
Question by:jeff-h
  • 2
3 Comments
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 40525456
If your query looks like (which looks like a crosstab):

Date           Dim01   Dim02    Dim03    Dim04
12/31/14    0.123     1.234      0.567      2.987
01/05/15    0.126     1.287      0.611      2.888

What does the actual data already look like?  It would probably be easier to change the query you have than to "normalize" the crosstab query.  However, the technique for normalizing a non-normal table like this is a union query:

SELECT [yourDate], "Dim01" as Dimension, [Dim01] as DimValue FROM yourQuery
UNION ALL
SELECT [yourDate], "Dim02" as Dimension, [Dim02] as DimValue FROM yourQuery
UNION ALL
SELECT [yourDate], "Dim03" as Dimension, [Dim03] as DimValue FROM yourQuery
UNION ALL
SELECT [yourDate], "Dim04" as Dimension, [Dim04] as DimValue FROM yourQuery

BTW, [Date], [Dim], and [Value] are reserved words in Access, so if you want to use those as column headers, you will have to wrap them in brackets.  Personally, I prefer to change the column headers as I did above.
0
 

Author Closing Comment

by:jeff-h
ID: 40525507
Absolutely fantastic, thanks a million Dale!
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 40525581
glad I could help
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now