VLOOKUP & MIN date

LEXCERM

Active Member
Joined
Jun 26, 2004
Messages
320
Office Version
  1. 365
Platform
  1. Windows
Hi,

I would like a formula to:-

a) Find the MIN value in ColB which corresponds to value "A" in ColA (which will be 01-Feb)
b) Return the corresponding value in ColC (which will be 15-Feb)

Bearing in mind I have hundreds of rows with similar data but different values in ColA.

ColAColBColC
A
03-Feb​
01-Feb​
A
05-Feb​
08-Feb​
A
01-Feb​
15-Feb​

Also, if ColA was the last column, can this be achieved by using INDEX/MATCH etc?

Many thanks in advance. :)
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Here is one way. Assuming that your data is in the range A2:C4:
Excel Formula:
=XLOOKUP(MINIFS(B2:B4,A2:A4,"A"),B2:B4,C2:C4)
 
Upvote 0
Here is one way. Assuming that your data is in the range A2:C4:
Excel Formula:
=XLOOKUP(MINIFS(B2:B4,A2:A4,"A"),B2:B4,C2:C4)
Many thanks @Joe4 for this. I have one question. It works fine for that small example, however, when I add around 10,000 rows of data (and I have extended the range in the formula etc), the results don't match at all. Are there any limitations to this? I've tried using $ to keep the range in tact and other methods, but not quite getting the desired result. Thanks again.
 
Upvote 0
Many thanks @Joe4 for this. I have one question. It works fine for that small example, however, when I add around 10,000 rows of data (and I have extended the range in the formula etc), the results don't match at all. Are there any limitations to this? I've tried using $ to keep the range in tact and other methods, but not quite getting the desired result. Thanks again.
Sounds like you may not be doing something correctly with the formula, or may have a data issue (multiple records with the same date).

The formula, locked-down, should look something like this:
Excel Formula:
=XLOOKUP(MINIFS($B$2:$B$4,$A$2:$A$4,"A"),$B$2:$B$4,$C$2:$C$4)
But are you hard-coding in the "A" part, or using a cell reference?
If using a cell reference, that one should NOT be locked down.
 
Upvote 0
Sounds like you may not be doing something correctly with the formula, or may have a data issue (multiple records with the same date).

The formula, locked-down, should look something like this:
Excel Formula:
=XLOOKUP(MINIFS($B$2:$B$4,$A$2:$A$4,"A"),$B$2:$B$4,$C$2:$C$4)
But are you hard-coding in the "A" part, or using a cell reference?
If using a cell reference, that one should NOT be locked down.

I have pretty much tried all those. Here is what I have found (and the results are the same without filtering). This is the result after applying the filter:-

1708708259321.png


The date in ColD does not exist in the dataset.

However, if I apply the resized range around that dataset, I get the correct results:-

1708708012303.png


Hence why I asked about limitations.

Or maybe I'm missing something glaringly obvious lol!

Many thanks.
 

Attachments

  • 1708708179224.png
    1708708179224.png
    38.7 KB · Views: 4
Upvote 0
Do you have the calculation mode set to manual?
It seems odd to me that all the values in column D have the same answer. That often indicates calculation mode is set to manual.
If you hit the F9 key (calculate), does it change the values?
 
Upvote 0
Do you have the calculation mode set to manual?
It seems odd to me that all the values in column D have the same answer. That often indicates calculation mode is set to manual.
If you hit the F9 key (calculate), does it change the values?
Calculation is set to Auto. ColD values are fine. It's looked up ColB for the min date (which is 20/9/2023), then returns the date which corresponds in ColC (4/12/2023). And this is for the values "A".
 
Upvote 0
OK, I see why. In the XLOOKUP part, we need to add the criteria to match to cell A4370 there also. Otherwise, we if other values for column A have the same date value for what we found with MINIFS, it could erroneously return those.

Try this:
Excel Formula:
=XLOOKUP(1,($B$2:$B$25522=MINIFS($B$2:$B$25522,$A$2:$A$25522,A4370))*($A$2:$A$25522=A4370),$C$2:$C$25522)
 
Upvote 1
Solution
OK, I see why. In the XLOOKUP part, we need to add the criteria to match to cell A4370 there also. Otherwise, we if other values for column A have the same date value for what we found with MINIFS, it could erroneously return those.

Try this:
Excel Formula:
=XLOOKUP(1,($B$2:$B$25522=MINIFS($B$2:$B$25522,$A$2:$A$25522,A4370))*($A$2:$A$25522=A4370),$C$2:$C$25522)
I shall try this soon and get back to you, but thank you so much for the help. Much appreciated.
 
Upvote 0

Forum statistics

Threads
1,223,713
Messages
6,174,041
Members
452,542
Latest member
Bricklin

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