Turning Columns into Rows - Any easy way?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hardcode
    New Member
    • Oct 2006
    • 3

    Turning Columns into Rows - Any easy way?

    I can't do it in Crystal Repots either without making a formula for each field so I thought about using 'copy an existing table structure wo/the data' (like to make a new table and append records to eliminate duplicates) to an increased field element table but that did not work even adding a qry...
    I just want to take a random number of rows of patient id's containing lab data and as the qry reads the rows, post the lab data from each row into one single row into a new table.
    It's the easiest thing that always causes the most exhasperation!
  • PEB
    Recognized Expert Top Contributor
    • Aug 2006
    • 1418

    #2
    Hi,

    There is a way to do it... :)

    You need to create a complementary table in which you insert the column names of your table with data... I suppose that in your Destination row table will be a field tha describes what kind information is it...

    So when the complementary table is ready you create an Append query

    based on the complementary table and your source table... You don't make a join btwn them!

    Int the field description you put the field from the complementary table...

    For the field with the information is a bit more difficult...

    For it you need for the function Switch, the ID of the respective record and function like dlookup and all this in combination like:

    Information: Switch([Description]="Field1", Dlookup("Field1 ","Mytable","ID ="+str([ID])),[Description]="Field2", Dlookup("Field2 ","Mytable","ID ="+str([ID])),.....,[Description]="Fieldn", Dlookup("Fieldn ","Mytable","ID ="+str([ID])))


    So this is all!

    :)

    Comment

    • hardcode
      New Member
      • Oct 2006
      • 3

      #3
      Thank you, this will make my life quite a bit easier, I do crystal reporting and it's pretty difficult in that realm, appreciate it !


      Originally posted by PEB
      Hi,

      There is a way to do it... :)

      You need to create a complementary table in which you insert the column names of your table with data... I suppose that in your Destination row table will be a field tha describes what kind information is it...

      So when the complementary table is ready you create an Append query

      based on the complementary table and your source table... You don't make a join btwn them!

      Int the field description you put the field from the complementary table...

      For the field with the information is a bit more difficult...

      For it you need for the function Switch, the ID of the respective record and function like dlookup and all this in combination like:

      Information: Switch([Description]="Field1", Dlookup("Field1 ","Mytable","ID ="+str([ID])),[Description]="Field2", Dlookup("Field2 ","Mytable","ID ="+str([ID])),.....,[Description]="Fieldn", Dlookup("Fieldn ","Mytable","ID ="+str([ID])))


      So this is all!

      :)

      Comment

      • Dalia Allencher
        New Member
        • Feb 2011
        • 8

        #4
        Hello, I am working on converting columns to rows in access.

        I have three columns in a query, applican'ts first name, applicant's last name, and manager's name. I need to make a query such that applicant first name, applicant last name columns remain as the 1st and 2nd columns of the query, but managers names will appear as a row so that each manager can writer their decision reagarding each applicant.

        Could you help me with this? I don't know any coding.

        I appreciate your help.

        Comment

        Working...