Results 1 to 3 of 3
  1. #1
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591

    Crosstab Column Sorting

    I have this crosstab query.



    Code:
    TRANSFORM Sum(Data) AS SumOfData
    SELECT MACHINE, Shift
    FROM tblTopTen
    GROUP BY MACHINE, Shift_Order, Shift
    ORDER BY Shift_Order, Rank
    PIVOT Rank;
    When I use Rank as my column header and sort ascending on it, it works perfectly except my Column Headers are no descriptive, i.e., 1, 2, 3 ... 10. This is the order I need it to sort in, but I also need Reason, the text description of the data, i.e., Broken, Out of Order, Paper Jam etc. When I do the the sort is off. I can't combine Rank and Text because it convert Rank to a string and sort incorrectly, i.e. 1-Broken, 10-Out_of_Order, 2-Paper Jam. The rank and reasons are dynamic, so I can force it in query design.

    I hope I've explained myself.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    The Rank would have to be formatted with leading zeros, like 01-Broken, 02-PaperJam, 10-Out_of_Order, then the alpha sort will work.
    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
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    Thanks, great tip.

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

Similar Threads

  1. Sorting Crosstab query results?
    By Dragongem in forum Queries
    Replies: 1
    Last Post: 06-13-2013, 09:21 PM
  2. Dynamic crosstab report sorting headings & dlookup
    By chrisangk in forum Programming
    Replies: 9
    Last Post: 01-14-2013, 02:37 PM
  3. Sums in First Column of Crosstab
    By JRINC in forum Queries
    Replies: 1
    Last Post: 10-06-2011, 02:47 PM
  4. Crosstab Column names used
    By JRINC in forum Queries
    Replies: 3
    Last Post: 09-29-2011, 02:46 PM
  5. Replies: 2
    Last Post: 08-17-2011, 03:02 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