Results 1 to 4 of 4
  1. #1
    jamesrees02 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    2

    Convert a crosstab set of data to a flat list

    Hi,


    Need to try a solve a problem. I have a set of data in excel (100k+ rows) that I have imported into an access table. The problem with the data is that there are 12 columns for the months and I want this in a list format to import into another application.
    e.g.
    I have:
    Product, Jan, Feb, Mar, Apr, May, Jun, Jun, Jul, Aug, Sep, Oct, Nov, Dec
    ProdA, 0,0,0,0,0,0,100,0,0,0,50,0
    Prodb, 100,0,0,0,0,0,0,0,0,0,0,0
    Prodc, 0,0,10,10,10,0,0,0,0,0,0,0

    but I want it to look like this:
    Product, Month, Amount
    ProdA, 7,100
    Proda, 11,50
    Prodb,1,100
    Prodc, 3,10
    Prodc, 4,10
    Prodc, 5,10

    Is there some function in Access2010 to do this or will I need to write 12 select queries with a union?

    Thanks in advance!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    One SQL with UNION:

    SELECT Product, "Jan", As [Month], [Jan] As Amount FROM tablename
    UNION SELECT Product, "Feb", [Feb] FROM tablename
    ...;

    Do you need year?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    jamesrees02 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    2
    No need for year as its all 2012.

    Thanks for confirming.
    James

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    If this data is the result of a crosstab, what is the original data structure? Could an aggregate (GROUP BY) on the original data produce the output?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 10-26-2011, 01:47 PM
  2. Crosstab(?) list of software installed
    By UTMonkey in forum Queries
    Replies: 4
    Last Post: 06-25-2011, 11:59 PM
  3. Replies: 2
    Last Post: 04-07-2011, 10:15 AM
  4. Creating a Flat File with Signed Numeric Data Fields
    By two_smooth in forum Database Design
    Replies: 2
    Last Post: 10-27-2010, 08:31 AM
  5. NF1 from Flat Table Query
    By Denormalized in forum Queries
    Replies: 0
    Last Post: 12-15-2009, 01:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums