+ Reply to Thread
Results 1 to 7 of 7

Sorting then grouping

  1. #1
    Registered User
    Join Date
    10-21-2013
    Location
    oklahoma
    MS-Off Ver
    Excel 2010
    Posts
    10

    Sorting then grouping

    I need to sort a work sheet by first sorting the information by the oldest document date then put all of the same customers together while keeping the oldest document dates on top.

    custnum doc date
    ide000 8/15/2012
    ide000 1/1/2013
    ide000 6/1/2013
    mik452 8/30/2012
    mik452 10/1/2012
    mik452 10/11/13


    I hope this gives the idea of what I am looking to do.


    Maybe a little clarification of what I am needing to do will help get some information. Here is an example of the data I am working from after I do a simple sort...
    ide000 8/12/2012
    ide000 8/30/2012
    mik452 9/6/2013
    elo555 9/29/2013
    ide000 10/1/2013
    mik452 10/5/2013

    What I want to end up with is in the first example. Any help is appreciated.
    Last edited by gpowell; 10-22-2013 at 03:10 PM.

  2. #2
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Sorting then grouping

    This can be achieved by just using Sort. I don't have 2010, but I imagine it is close to 2007. Go to your Data ribbon and choose sort. A dialog box will come up.
    On 'Sort by' choose the custnum column and A to Z. Then hit the button that says 'Add Level'. A new row should be added in the dialog box that says 'Then by'. Choose the doc date column and then 'Smallest to Largest'.
    Pauley
    --------
    If I helped with your issue, I'd appreciate a rep bump (hit the '*' icon to the bottom left of this post).

  3. #3
    Registered User
    Join Date
    10-21-2013
    Location
    oklahoma
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Sorting then grouping

    Ok That helped but now I need to put the customers with the oldest document on the top but keep the customer group togeather. In other words keep all of the ide00 togeather but move them to the top then grab the mik452 and move it up. I may not be explaining myself well enough so let me know.
    Thanks

  4. #4
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Sorting then grouping

    Ok, I tried this and it seems to work (at least on the small amount of data)

    I added a helper column C and entered this Array Formula (entered with Ctrl + Shift + Enter) in C2 (data in A2 to B10)


    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Copy down the length of your data (change the references for the ranges as necessary)
    This will pick out the earliest date for each name in column A

    Now, do a custom sort. Sort on column C, Old to New.
    Then Column A, A to Z.
    Then column B, Old to New.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  5. #5
    Valued Forum Contributor
    Join Date
    10-14-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2019
    Posts
    353

    Re: Sorting then grouping

    I would suggest a 2-step sort
    First sort on date to get the oldest on top
    In column C I put a formula for the Ranking of customers
    Then sort on Rank + Date + Customer
    et voila......
    Attached Files Attached Files
    Kind regards,
    Piet Bom

  6. #6
    Registered User
    Join Date
    10-21-2013
    Location
    oklahoma
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Sorting then grouping

    Thanks newdoverman
    That did excatly what it is I needed however I can not figure out how just yet. I hate not knowing how something works.

  7. #7
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Sorting then grouping

    The formula =SMALL(IF($A$2:$A$10=A2,$B$2:$B$10),1) finds the smallest (oldest date) in column B that belongs to each name in column A. This value is constant for each name so, it can be sorted while keeping the names associated with them together.

    Then sort on the names and the dates and you end up with a list that has the oldest date with the associate name and all dates sorted in order for that name.

    Do one part of the sort at a time in the order given and you will see how the data becomes sorted in the manner you want.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Sorting and Grouping Problem
    By Ocris in forum Excel General
    Replies: 7
    Last Post: 07-15-2012, 03:59 PM
  2. Help with grouping/sorting
    By ceverett in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-26-2011, 04:00 PM
  3. Excel 2007 : Grouping and Sorting
    By iPaprika in forum Excel General
    Replies: 0
    Last Post: 01-26-2011, 03:49 PM
  4. Grouping and Sorting Help!!!!
    By computerjunkie in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-26-2007, 11:35 AM
  5. grouping and sorting data
    By mb7q in forum Excel General
    Replies: 0
    Last Post: 03-30-2006, 03:35 PM

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