Results 1 to 5 of 5
  1. #1
    tmcrouse is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Apr 2009
    Posts
    169

    Crosstab Query Help


    I have a very large table that I am trying to crosstab and cannot quit get it right. Here is an example of the data I have. There are many more columns with facilities rate information. The largest I have is 15 columns of the rates.
    Then for John Hopkins I need to do a query and thinking query by measure and where ever John Hopkins rate falls compared to others in that group they would be rated accordingly


    DATA HAVE
    JOHNHOPKINS LEAVERVILLE OXFORD market MEASURE
    0.5255 0.4514 0.4375 GA AWC
    0.8138 0.8356 0.8505 GA AAB 20-24
    0.7211 0.7066 0.7283 GA ADV 11-14
    0.6092 0.5981 0.6256 GA ADV 15-18
    0.3317 0.3577 0.3279 GA ADV 12-14
    0.4859 0.4428 0.4995 GA ADV 2-3
    0.7719 0.7509 0.7711 GA ADV 4-6
    DATA NEED
    MEASURE market FACILITY RATING RANKING
    AWC GA JOHN HOPKINS 0.5255 1 OUT OF 3
    AWC GA LEAVERVILLE 0.4514
    AWC GA OXFORD 0.4375
    AAB 20-24 GA JOHN HOPKINS 0.8138 3 OUT OF 3
    AAB 20-24 GA LEAVERVILLE 0.8356
    AAB 20-24 GA OXFORD 0.8505
    ADV 11-14 GA JOHN HOPKINS 0.7211 2 OUT OF 3
    ADV 11-14 GA LEAVERVILLE 0.7066
    ADV 11-14 GA OXFORD 0.7283
    ADV 15-18 GA JOHN HOPKINS 0.6092 2 OUT OF 3
    ADV 15-18 GA LEAVERVILLE 0.5987
    ADV 15-18 GA OXFORD 0.6256
    ADV 12-14 GA JOHN HOPKINS 0.3317 2 OUT OF 3
    ADV 12-14 GA LEAVERVILLE 0.3577
    ADV 12-14 GA OXFORD 0.3279
    ADV 2-3 GA JOHN HOPKINS 0.4859 2 OUT OF 3
    ADV 2-3 GA LEAVERVILLE 0.4428
    ADV 2-3 GA OXFORD 0.4995
    ADV 4-6 GA JOHN HOPKINS 0.7719 2 OUT OF 3
    ADV 4-6 GA LEAVERVILLE 0.7509
    ADV 4-6 GA OXFORD 0.7711

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    The DATA NEED table is how your data SHOULD have been stored. (normalized)
    The
    DATA HAVE is what the crosstab would produce.
    but since yours is backwards, youd have to make a series of append queries, to put data into a 'report' table.

  3. #3
    tmcrouse is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Apr 2009
    Posts
    169
    This is the way the data comes over as the data have. I will just have to manually do it I guess. Thanks

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    This does not call for CROSSTAB. Data is already not normalized and de-normalizing/summarizing data is what CROSSTAB does.

    A UNION query can rearrange the data into normalized structure. Then use the UNION query as source for subsequent queries. Such as a query that sorts records by the rating value.

    SELECT market, measure, JOHNHOPKINS AS Rating, "JOHNHOPKINS" AS Facilty FROM tablename
    UNION SELECT market, measure, LEAVERVILLE, "LEAVERVILLE" FROM tablename
    UNION SELECT market, measure, OXFORD, "OXFORD" FROM tablename;

    There is a limit of 50 SELECT lines. There is not query builder for UNION, must type into SQL View of query designer.

    It's the ranking calculation to show "1 out of 3" that complicates this. If you have up to 15 facility columns to compare, I expect VBA custom function will be involved.
    Last edited by June7; 10-22-2015 at 11:54 PM.
    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.

  5. #5
    DrGUI is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Aug 2015
    Location
    Parts Unknown
    Posts
    23
    See if this does it for you.

    It should handle any number of rate columns and will also calculate the ranking against the other rates.
    Attached Files Attached Files

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

Similar Threads

  1. Crosstab Query Help?
    By gyull in forum Queries
    Replies: 1
    Last Post: 03-19-2015, 06:26 PM
  2. Replies: 2
    Last Post: 04-30-2014, 03:01 PM
  3. Replies: 2
    Last Post: 08-16-2013, 01:36 AM
  4. crosstab query can do this ?
    By pinky in forum Access
    Replies: 4
    Last Post: 01-27-2012, 11:37 AM
  5. Replies: 1
    Last Post: 07-30-2010, 10:28 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