+ Reply to Thread
Results 1 to 11 of 11

Incorrect sort order on Pivot Table

  1. #1
    Registered User
    Join Date
    11-01-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    19

    Incorrect sort order on Pivot Table

    I have a Pivot Table where the row labels are numeric values between 0 and 150. I have decided to group them by 5s (right click row entry choose Group from the popup menu).

    whenever I do this, the sort order gets confused. When they are ungrouped it is correct and the rows of the pivot table are sorted correctly, because it treats the entries as numbers so it's sorting them numerically. Then they are grouped, the row entries contain text strings, for example:

    0-4
    5-9
    10-14

    etc.

    So for values over 100, it ends up showing like this:


    0-4
    5-9
    10-14
    105-109
    145-150
    15-19

    etc. Is there a way to make this work correctly without resorting to manual sorting?

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: Incorrect sort order on Pivot Table

    I made up some fake data but can't replicate your problem. Please attach your workbook.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    11-01-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Incorrect sort order on Pivot Table

    Quote Originally Posted by 6StringJazzer View Post
    I made up some fake data but can't replicate your problem. Please attach your workbook.
    I discovered after posting that that you're right - it doesn't replicate easily. i did figure out the steps to replicate it though.

    0.5) Make sure the data source has blank rows in it
    1) Group the numbers according to some interval (note the groupings are sorted correctly)
    2) Right click one of the rows and choose Sort Ascending A->Z
    3) (Note that it sorted lexicographically which is incorrect)
    4) Ungroup the cells
    5) Regroup the cells

    At this point there seems to be no going back short of Ctrl+Z (which is not an option for me since I've made numerous changes since the point at which I originally made the mistake of sorting A->Z.

    I've attached a workbook.
    Attached Files Attached Files
    Last edited by bruiser; 11-09-2010 at 04:36 AM.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: Incorrect sort order on Pivot Table

    There is no pivot table in this attachment.

  5. #5
    Registered User
    Join Date
    11-01-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Incorrect sort order on Pivot Table

    Err, that was embarassing. Not sure what happened there. Thanks for your patience anyway

    Try the attached workbook.
    Attached Files Attached Files

  6. #6
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Incorrect sort order on Pivot Table

    0.5) Make sure the data source has blank rows in it
    One of the ground rules of pivot tables is that the data source should not have blank rows.

  7. #7
    Registered User
    Join Date
    11-01-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Incorrect sort order on Pivot Table

    Quote Originally Posted by teylyn View Post
    One of the ground rules of pivot tables is that the data source should not have blank rows.
    Hmm, well since the data comes from a constantly growing database to which I am regularly adding new rows, how do I address the issue of not wanting to go maintain the named range which represents the actual database every single time I add more rows, but still allow the Pivot Table to automatically pick up the newly entered data?

    Is there a way to, like, define a named range where the bounds of the range are conditional? So like I have the main database which contains blank rows, and then define another range which always contains the subset of the larger range which has everything up until the first blank row?

    This doesn't seem like too strange of a use case.

  8. #8
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: Incorrect sort order on Pivot Table

    I think you want to use a List. The List automatically expands the boundary when you add rows.

    http://office.microsoft.com/en-us/ex...433.aspx?CTT=3

  9. #9
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Incorrect sort order on Pivot Table

    The List automatically expands the boundary when you add rows.
    not when you leave complete rows blank...

  10. #10
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: Incorrect sort order on Pivot Table

    Quote Originally Posted by teylyn View Post
    not when you leave complete rows blank...
    My impression of what bruiser was doing was including blank rows at the end of his data range just to allow room to add more data and still be included in the pivot table. A list solves that. If instead, he wants to have blank rows in the middle of his data, then yes, a list won't handle that.

  11. #11
    Registered User
    Join Date
    10-24-2012
    Location
    Ann Arbor, MI
    MS-Off Ver
    Excel 2010
    Posts
    1

    Cool Re: Incorrect sort order on Pivot Table

    1. Ungroup your data
    2. Sort Ascending or Descending
    3. Go to More Sort Options
    4. Change to Manual and click ok again
    5. Regroup how you want your data


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1