Results 1 to 3 of 3
  1. #1
    denver1717 is offline Novice
    Windows XP Access 2000
    Join Date
    Oct 2012
    Posts
    16

    Transposing a table within Access (and getting the same results as transposing the same table in Exc


    I have been researching this on the web, and have seen a bunch of stuff on union queries and I am familiar with crosstab queries.

    Basically I want to do within Access exactly what I can do in Excel as far as copying and transposing a data selection. Below is the table I am trying to transpose (first table). I want the Audit 1, Audit 2, Audit 3, Audit 4... to be in the rows with the Question being each column header (see the second table I posted). I will have hundreds of Audits in a file, it is not limited to 5. It's making me crazy I can't figure it out. Ultimately I will add a "question" to the transposed dataset that will be a value of 1 so that for each audit (which is representative of a patient event) I will be able to quantify queries which are question based. I did try adding a value of one and working through this as a crosstab in Access but I didn't get anywhere with it.


    So here is my untransposed data table:
    Question Audit 1 Audit 2 Audit 3 Audit 4 Audit 5
    Date of event 1/1/12 1/2/12 1/3/12 1/4/12 1/5/12
    Time of event 6:51 AM 11:40 AM 6:26 AM 8:18 AM 9:46 PM
    Nursing unit a b c d e
    POCT BG value 1 2 3 4 3
    Type 1 2 other 1 2
    Provider Bob Mike Sue Ann Joe
    Endocrine no no no no no
    Diabetes Medications given within 24 hours of event
    Levemir no no no no no
    Novolog scheduled meal dose no no no no no
    Novolog correction scale yes yes yes yes yes
    U-500 no no no no no
    NPH no no no no no
    Mixed Insulin no no no no no
    Insulin Pump no no no no no
    Sulfonylureas (Giipizide, Glucotrol, Glimepiride, Glyburide): no no no no no
    Meglitinides (Nateglinide, Repaglinide) no no no no no
    Other yes no no no no
    If other, please describe Trulicity 7/29/17 no no no no
    no no no no no
    Nutritional intake prior to hypoglycemia NPO PO diet PO diet PO diet PO diet
    Patient's last documented weight in pounds 0.00 0.00 0.00 0.00 0.00
    no no no no no
    Associated risks no no no no no
    eGFR <30 no no no no no
    Dialysis no no no no no
    Corticosteroids (Methylprednisolone, Solu-Medrol, Solu-Cortef, Prednisone) yes no no no no
    Were home insulin doses continued in the hospital? no no no no no
    no no no no no
    Treatment provided no no no no no
    4-oz. juice yes no no no no
    Glucose gel no yes yes yes yes
    D50% IVP no yes yes yes yes
    Glucagon no no no no no
    Other no no no no no
    If other, please describe no no no no no
    Not documented no no no no no
    Follow up POCT done in 15-30 minutes? no yes yes yes no
    no no no no no
    Provider notified of hypoglycemic event yes yes yes yes yes
    no no no no no
    Event documented by nurse yes yes yes yes yes
    no no no no no
    Causative factor no no no no no
    Home insulin continued no no no no no
    High basal dose no no no no no
    Sulfonylurea no no no no no
    High correction dose no no no no no
    Insulin not synchronized with food no no no no no
    Correction not admin. within 30 minutes of BG test no no no no no
    Med error no no no no no
    Other/Comments had long agent name pancreatic cancer creative



    (Here is what I would like the final access output (table) to look like (via the access query I am hoping to compose - I did the below transpose in Excel):
    Question Date of event Time of event Nursing unit POCT BG value Type Provider Endocrine Diabetes Medications given within 24 hours of event Levemir Novolog scheduled meal dose Novolog correction scale U-500 NPH Mixed Insulin Insulin Pump Sulfonylureas (Giipizide, Glucotrol, Glimepiride, Glyburide): Meglitinides (Nateglinide, Repaglinide) Other If other, please describe Nutritional intake prior to hypoglycemia Patient's last documented weight in pounds Associated risks eGFR <30 Dialysis Corticosteroids (Methylprednisolone, Solu-Medrol, Solu-Cortef, Prednisone) Were home insulin doses continued in the hospital? Treatment provided 4-oz. juice Glucose gel D50% IVP Glucagon Other If other, please describe Not documented Follow up POCT done in 15-30 minutes? Provider notified of hypoglycemic event Event documented by nurse Causative factor Home insulin continued High basal dose Sulfonylurea High correction dose Insulin not synchronized with food Correction not admin. within 30 minutes of BG test Med error Other/Comments
    Audit 1 1/1/12 6:51 AM a 1 1 Bob no no no yes no no no no no no yes Trulicity 7/29/17 no NPO 0.00 no no no no yes no no no yes no no no no no no no no yes no yes no no no no no no no no no had long agent name
    Audit 2 1/2/12 11:40 AM b 2 2 Mike no no no yes no no no no no no no no no PO diet 0.00 no no no no no no no no no yes yes no no no no yes no yes no yes no no no no no no no no no pancreatic
    Audit 3 1/3/12 6:26 AM c 3 other Sue no no no yes no no no no no no no no no PO diet 0.00 no no no no no no no no no yes yes no no no no yes no yes no yes no no no no no no no no no cancer
    Audit 4 1/4/12 8:18 AM d 4 1 Ann no no no yes no no no no no no no no no PO diet 0.00 no no no no no no no no no yes yes no no no no yes no yes no yes no no no no no no no no no creative
    Audit 5 1/5/12 9:46 PM e 3 2 Joe no no no yes no no no no no no no no no PO diet 0.00 no no no no no no no no no yes yes no no no no no no yes no yes no no no no no no no no no


    Worse comes to worse I can just transpose it in Excel, but I would love to write it into the access database I am creating.

    Thank you for any help, it is appreciated more than you know!!! It is making me crazy I can't get my mind around this. I believe I will have to normalize my data via a union query, but I am not quite understanding that process and I am not familiar with union queries.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Hundreds of audits? Cannot have hundreds of audit fields. There is a limit of 255 fields in a table and query.

    Is there a field for PatientID?

    Your data structure is not normalized.

    A UNION query can rearrange data to normalized structure. However, there is a limit of 50 SELECT lines. So using your posted example data:

    SELECT PatientID, "Audit1" AS AuditSeq, Audit1 AS Data, Question FROM tablename
    SELECT PatientID, "Audit2", Audit2, Question FROM tablename
    SELECT PatientID, "Audit3", Audit3, Question FROM tablename
    SELECT PatientID, "Audit4", Audit4, Question FROM tablename
    SELECT PatientID, "Audit5", Audit5, Question FROM tablename;

    This is more like the normalized structure your table should be.

    Now use that query as source for CROSSTAB with PatientID and AuditSeq as row headers and Question as column header and Data as the value using First() function.
    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
    denver1717 is offline Novice
    Windows XP Access 2000
    Join Date
    Oct 2012
    Posts
    16
    Quote Originally Posted by June7 View Post
    Hundreds of audits? Cannot have hundreds of audit fields. There is a limit of 255 fields in a table and query.

    Is there a field for PatientID?

    Your data structure is not normalized.

    A UNION query can rearrange data to normalized structure. However, there is a limit of 50 SELECT lines. So using your posted example data:

    SELECT PatientID, "Audit1" AS AuditSeq, Audit1 AS Data, Question FROM tablename
    SELECT PatientID, "Audit2", Audit2, Question FROM tablename
    SELECT PatientID, "Audit3", Audit3, Question FROM tablename
    SELECT PatientID, "Audit4", Audit4, Question FROM tablename
    SELECT PatientID, "Audit5", Audit5, Question FROM tablename;

    This is more like the normalized structure your table should be.

    Now use that query as source for CROSSTAB with PatientID and AuditSeq as row headers and Question as column header and Data as the value using First() function.

    Thank you so much for responding! I do have a patient ID field. I think I understand what you are suggesting.


    If I can only do 50 lines (Patient IDs/audit columns) at the same time, that is fine. So far the files I have been receiving only have 15 or so audits populated in them (I am going to keep appending each audit file to the master access table you're helping me build).


    I will try what you suggested first thing tomorrow (I don't have MS Access on my personal laptop), I am hopeful it will work. Thank you again, I really appreciate your help!

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

Similar Threads

  1. Transposing Linked Data
    By Rustin788 in forum Access
    Replies: 4
    Last Post: 03-09-2017, 03:46 PM
  2. Transposing row to column in Access 2010
    By nshatz in forum Access
    Replies: 2
    Last Post: 06-02-2015, 10:38 AM
  3. transposing data in a report
    By brianrunsphilly in forum Reports
    Replies: 3
    Last Post: 10-23-2013, 02:22 PM
  4. Transposing Columns to Rows
    By hycho in forum Programming
    Replies: 5
    Last Post: 07-19-2012, 01:17 AM
  5. Transposing Data
    By NoiCe in forum Queries
    Replies: 0
    Last Post: 11-09-2008, 05:24 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