View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Toppers
 
Posts: n/a
Default Matching max in a subgroup with corresponding data pair

If orders aere sorted by Ascending customer number and DESCENDING date then:

To get date:

=INDEX($B$2:$B$9,MATCH(A11,$A$2:$A$9,0))

to get qty:

=INDEX($C$2:$C$9,MATCH(A11,$A$2:$A$9,0))

If BOTH are sorted ASCENDING then:

=INDEX($B$2:$B$9,MATCH(A11,$A$2:$A$9,0)+COUNTIF($A $2:$A$9,A11)-1)

and (enter as array formula with Ctrl+ShiFt+Enter)

=INDEX($C$2:$C$9,MATCH(1,($A$2:$A$9=A11)*($B$2:$B$ 9=B11),0))

Sample below:

Customer Date Quantity
1 05/03/2006 2
1 12/04/2006 5
1 10/05/2006 4
2 01/03/2006 3
2 04/05/2006 4
3 12/02/2006 2
3 19/03/2006 1
3 22/05/2006 7

1 10/05/2006 4 <==row 11
2 04/05/2006 4
3 22/05/2006 7

HTH


" wrote:

I'm trying to write a function which returns the quantity purchased
from the most recent order given a list of customers, order dates, and
quantities.

Input would look like this:
Customer # Order date Quantity
1 3/5/06 2
1 4/12/06 5
1 5/19/06 4
2 1/3/06 3
2 4/5/06 4
3 2/12/06 2
3 3/19/06 1
3 5/22/06 7

Results would look like:

Customer # Most Recent Order Quantity
1 5/19/06 4
2 4/5/06 4
3 5/22/06 7


I've been trying to use INDEX(MATCH) but have not been successful,
probably because its the Friday of a long weekend.

Thanks again for everyone's help - Happy 4th.

JC