Solved

ms access transpose columns and values to rows

Posted on 2014-12-31
3
1,851 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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…

739 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