Trying to sort by date, but group matching field

rondeaul

New Member
Joined
Sep 14, 2017
Messages
10
I've been all over the different questions and answers and can't seem to find one that fits my situation.
I have a large list of data (sales orders) where we might get multiple sales orders for the same client. I'm trying to sort the overall list by date but then group all orders for the same client together so the newer orders are brought forward with the oldest sales order for that client. The key is we are working on clients with the oldest sales order first, so I don't simply want to sort by client and then date. I'm not sure how to get where I need to go. Any suggestions?


Current outputDesired Output
Client NameStatusOrder DateClient #Client NameStatusOrder DateClient #
client 12Active5/17/20181620858client 12Active5/17/20181620858
Client 1Active6/1/20181628914client 12Active6/23/20181620858
client 10Hold6/5/20181630746Client 1Active6/1/20181628914
client 4Hold6/5/20181630546Client 1Active6/23/20181628914
client 9Hold6/5/20181630410client 10Hold6/5/20181630746
client 7Active6/7/20181479678client 10Hold6/23/20181630746
Client 2Hold6/11/20181634284client 4Hold6/5/20181630546
Client 1Active6/23/20181628914client 4Hold6/23/20181630546
client 10Hold6/23/20181630746client 9Hold6/5/20181630410
client 11Rolled6/23/20180128596client 7Active6/7/20181479678
client 12Active6/23/20181620858Client 2Hold6/11/20181634284
Client 2Hold6/23/20181634284Client 2Hold6/23/20181634284
client 4Hold6/23/20181630546client 11Rolled6/23/20180128596
client 8Active6/23/20180632193client 8Active6/23/20180632193
client 3Active8/2/20181639915client 3Active8/2/20181639915
client 5Active8/8/20181623580client 3Active9/5/20181639915
client 3Active9/5/20181639915client 5Active8/8/20181623580
client 6Active9/7/20181589648client 6Active9/7/20181589648

<colgroup><col><col><col><col><col span="2"><col><col><col><col></colgroup><tbody>
</tbody>

<colgroup><col><col><col><col><col span="2"><col><col><col><col></colgroup><tbody>
</tbody>
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Pivot Table Reporting:
Place the the fields in the ROWS area.
Also add the Oder date to the Values Area, Left click on the Order Date in Values area and select the Value Field Settings. Change to MIN.
From the Pivot Table ribbon/Design Ribbon, set the Report Layout to Tabular. Set Repeat All Labels
Under Grand Totals, select OFF for Row and Columns
Under Subtotals, Do not Show Subtotals.

On the pivot Table, Right Click a Client Name. Choose SORT... More Sort Options. Set for ASCENDING by Min of Order Date.
 
Upvote 0
Thank you SpillerBD, but I have too much data to be able to use a pivot table. I only included a small sample of the data but the report can run anywhere from 50 to 1,000+ rows and typically has about 70 columns. That is the overall data I am trying to sort and group.
 
Upvote 0
Too big for a Pivot Table? Only a thousand rows! Its the columns that get ugly and some of those other little quirks....

For the Range/Table you will need a helper column and array formula to group each Client Name by the MIN(Order Date), then you'd be able to sort by that date, the Client Name and the Order Date.

Where Column "A" refers to the column of Client Names and column "C" refers to the Order Date
Code:
=MIN(IF($A$2:$A$19=A2,$C$2:$C$19))
Use CTRL+SHIFT+ENTER to enter formula as Array Formula.
 
Upvote 0
Not sure I fully understand the requirement, but adding this helper column and then sorting on that new column produces the expected results for the sample data.
(Note that my dates are in d/m/y format)

Excel Workbook
ABCDE
1Client NameStatusOrder DateClient #
2client 12Active17/05/201816208581
3Client 1Active6/01/201816289142
4client 10Hold6/05/201816307463
5client 4Hold6/05/201816305464
6client 9Hold6/05/201816304105
7client 7Active6/07/201814796786
8Client 2Hold6/11/201816342847
9Client 1Active23/06/201816289142
10client 10Hold23/06/201816307463
11client 11Rolled23/06/201812859610
12client 12Active23/06/201816208581
13Client 2Hold23/06/201816342847
14client 4Hold23/06/201816305464
15client 8Active23/06/201863219314
16client 3Active8/02/2018163991515
17client 5Active8/08/2018162358016
18client 3Active9/05/2018163991515
19client 6Active9/07/2018158964818
Sort




After sorting:

Excel Workbook
ABCDE
1Client NameStatusOrder DateClient #
2client 12Active17/05/201816208581
3client 12Active23/06/201816208581
4Client 1Active6/01/201816289143
5Client 1Active23/06/201816289143
6client 10Hold6/05/201816307465
7client 10Hold23/06/201816307465
8client 4Hold6/05/201816305467
9client 4Hold23/06/201816305467
10client 9Hold6/05/201816304109
11client 7Active6/07/2018147967810
12Client 2Hold6/11/2018163428411
13Client 2Hold23/06/2018163428411
14client 11Rolled23/06/201812859613
15client 8Active23/06/201863219314
16client 3Active8/02/2018163991515
17client 3Active9/05/2018163991515
18client 5Active8/08/2018162358017
19client 6Active9/07/2018158964818
Sort
 
Last edited:
Upvote 0
Thank you SpillerBD. This worked as well, but in the end I used the Match function below. I was able to build that into a macro easier.
 
Upvote 0
II'm trying to sort the overall list by date but then group all orders for the same client together so the newer orders are brought forward with the oldest sales order for that client. The key is we are working on clients with the oldest sales order first, so I don't simply want to sort by client and then date.
It's not obvious because of the example used, but Peter's solution does not meet this criteria.
Resort by name and then try to resort for the desired results....
 
Upvote 0

Forum statistics

Threads
1,215,851
Messages
6,127,296
Members
449,374
Latest member
analystvar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top