Date of Max value

Tikey

Board Regular
Joined
Jan 30, 2014
Messages
148
Office Version
  1. 2021
Platform
  1. Windows
Hi

I’m using Office pro plus 2021.

I am trying to find the date of the maximum number, when 2 conditions are true, the year and a code. The following is an example sheet, in reality the sheet could contain 50000 rows of data and the columns may not be adjacent.

This sometimes can appear to work OK, but depending on the combination of date / number, can sometimes return a date for the wrong year.

CodeDateNumber
A
02/06/1995​
1​
b
03/06/1995​
7​
b
04/06/1995​
9​
A
05/06/1995​
1​
A
06/06/1995​
2​
b
07/06/1995​
6​
A
08/06/1995​
1​
A
09/08/1996​
1​
A
10/08/1996​
1​
b
11/08/1996​
12​
b
12/08/1996​
10​
A
13/08/1996​
1​
A
14/08/1996​
2​
A
15/08/1996​
11​
A
16/08/1996​
5​
A
24/07/2001​
9​
A
25/07/2001​
5​
A
26/07/2001​
2​
A
27/07/2001​
4​
A
28/07/2001​
1​
A
29/07/2001​
1​


=INDEX(C2:C22,MATCH(MAX(IF((B2:B22="A")*(YEAR(C2:C22)=2001),D2:D22)),D2:D22,0))

In the above I would expect 24/07/2001 to be the answer, but it returns 04/06/1995, which is the wrong year and code.

Any help appreciated.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
How about
Fluff.xlsm
ABCDE
1CodeDateNumber
2A02/06/1995124/07/2001
3b03/06/19957
4b04/06/19959
5A05/06/19951
6A06/06/19952
7b07/06/19956
8A08/06/19951
9A09/08/19961
10A10/08/19961
11b11/08/199612
12b12/08/199610
13A13/08/19961
14A14/08/19962
15A15/08/199611
16A16/08/19965
17A24/07/20019
18A25/07/20015
19A26/07/20012
20A27/07/20014
21A28/07/20011
22A29/07/20011
Data
Cell Formulas
RangeFormula
E2E2=INDEX(SORT(FILTER(B2:C100,(A2:A100="A")*(YEAR(B2:B100)=2001)),2,-1),1,1)
 
Upvote 0
Thank you that works fine for the example, but as I indicated in the post, the columns may not be adjacent and in this situation it doesn't work. Not sure if columns B and C could be seperated, rather than B2:C100 ?
 
Upvote 0
Try
Excel Formula:
=INDEX(SORT(FILTER(CHOOSE({1,2},B2:B100,C2:C100),(A2:A100="A")*(YEAR(B2:B100)=2001)),2,-1),1,1)
 
Upvote 0
Solution
Thank you, that works great, much appreciated.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,071
Messages
6,122,964
Members
449,094
Latest member
Anshu121

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