Results 1 to 5 of 5
  1. #1
    peteramullen is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    3

    Converting matrix to column in access 2010

    Hello all,

    I'm trying to convert a matrix within a table (m x n) to a single column. So basically

    1 2 3


    4 5 6
    7 8 9

    to

    1
    2
    3
    4
    5
    6
    7
    8
    9

    I would do this in excel, but the problem is I have already over 1 million rows, and I'm converting 48 columns into one (too much for excel). Is there a way to do this via a macro or query?

    The other catch is that I want to repeat Column A (which has the username) with each row of data, for example

    Joe 1 2 3
    Sam 4 5 6
    Jeff 7 8 9

    to

    Joe 1
    Joe 2
    Joe 3
    Sam 4
    Sam 5
    Sam 6
    Jeff 7
    Jeff 8
    Jeff 9

    any ideas or thoughts would be amazingly appreciated! Thanks!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    How about a UNION query?

    SELECT ColumnA, ColumnB
    FROM TableName
    UNION ALL
    SELECT ColumnA, ColumnC
    FROM TableName
    UNION ALL
    ...
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    peteramullen is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    3
    Thanks pbaldy, that has already helped a lot. A follow up question has spawned though:

    How can I get ColumnB, Column C, etc names to be associated with those rows?


    Basically I won't be able to tell which column they came from unless they are somehow designated to have come from that column..

    Any help there? Sorry am new to access..

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Try

    SELECT ColumnA, ColumnB, "ColumnB" As Source
    FROM TableName
    UNION ALL
    SELECT ColumnA, ColumnC, "ColumnC" As Source
    FROM TableName
    UNION ALL
    ...
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    peteramullen is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    3
    Thanks again, worked great.

    I realized that there are some values that need to be summed -- the Column B values, Column C values etc, within each Column A category.

    How do I go about subtotaling?

    I currently have been trying to query a total off of this initial query we've been discussing above. I'd be great if I could embed it in the original SQL code though. Thanks for all the help!!!

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

Similar Threads

  1. VBA Programming of P_I Matrix in Access
    By Bretz217 in forum Programming
    Replies: 19
    Last Post: 02-25-2013, 08:20 AM
  2. Replies: 0
    Last Post: 07-31-2012, 12:25 PM
  3. ramifications of converting a db 2007 to 2010
    By stevepcne in forum Access
    Replies: 6
    Last Post: 11-17-2011, 05:20 PM
  4. Converting to access from Excel
    By Alexpi in forum Database Design
    Replies: 3
    Last Post: 05-24-2011, 02:46 PM
  5. matrix display
    By radujit in forum Queries
    Replies: 1
    Last Post: 01-25-2011, 10:37 AM

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