find most recent occurrences

vicndave

New Member
Joined
Aug 5, 2023
Messages
3
Platform
  1. Windows
Given raw data in A1:D4 showing values for certain dates,
A​
B​
C​
D​
E​
F​
G​
H​
I​
1​
Date​
Val1​
Val2​
Val3​
All Vals​
latest date​
2nd latest​
3rd latest​
2​
04/02/23​
Aaron​
Barbara​
Evan​
Aaron​
04/23/23​
04/16/23​
04/02/23​
3​
04/09/23​
Barbara​
Charlie​
Dorcas​
Barbara​
04/23/23​
04/09/23​
04/02/23​
4​
04/16/23​
Frank​
Heather​
Aaron​
Charlie​
04/23/23​
04/09/23​
5​
04/23/23​
Charlie​
Aaron​
Barbara​
Dorcas​
04/09/23​
6​
Evan​
04/02/23​
7​
Frank​
04/16/23​
8​
Greta​
9​
Heather​
04/16/23​

What formula(s) can produce the data in F1:I9. showing the 3 most recent dates the value in column F occurred in any of columns B through D?

I can find functions that do parts of what I want, but I'm having trouble combining them into formulas to get the complete behavior.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
Thank you for taking a look at this.

I didn't specify version because the file is shared among multiple users. I think all are on Windows, but versions include 365, some unknown versions of Excel, and even LibreOffice 7.2.1.2 (x64) Calc. I'd be happy to get it working in any of these, but we can start with 365.

My mistake, the formulas should be in G2:I9, not F1:I9. Column F is the master value list, and values in columns B-D are taken from column F. The absence of Greta in columns B through D is why there are no dates for Greta in G8:I8.

In 365 I created table 'data' with range A2:D5 and tried a number of things. For example, entering this formula in G2:
=IFERROR(INDEX(data[Date],SMALL(IF(data[Val2]=$F2,ROW(data)-MIN(ROW(data))+1),1)),"")

gives the right result by accident:
4/23/23

because it only looks for 'Aaron' in column C (Val2). If I modify the formula to look for 'Aaron' in B, C or D (Val1, Val2, Val3) as required:
=IFERROR(INDEX(data[Date],SMALL(IF(OR(data[Val1]=$F2,data[Val2]=$F2,data[Val3]=$F2),ROW(data)-MIN(ROW(data))+1),1)),"")

it gives the wrong result:
4/2/23
 
Upvote 0
Try these steps (tested to work in Excel 2010 and above):
1) Copy the following formula and paste it in cell G2
Excel Formula:
=IFERROR(AGGREGATE(14,6,data[Date]*SIGN(SEARCH($F2,data[Val1]&"|"&data[Val2]&"|"&data[Val3])),{1,2,3}),"")
2) Select range G2:I2;
3) Press the F2 key -- you should see a blinking cursor at the end of the formula;
4) Press and hold the Ctrl and Shift keys, then press the Enter key -- you should see range G2:I2 populated;
5) Drag-copy range G2:I2 down as needed.
 
Last edited:
Upvote 1
Try these steps (tested to work in Excel 2010 and above):
I would suggest a slight tweak to avoid a possible error like G7 below (I have added to & changed the sample data).
Changed suggestion in bottom section of columns F:I

23 08 07.xlsm
ABCDEFGHI
1DateVal1Val2Val3All Valslatest date2nd latest3rd latest
22/04/2023AaronBarbaraEvanAaron23/04/202316/04/20232/04/2023
39/04/2023BarbaraCharlieDorcasBarbara23/04/20239/04/20232/04/2023
416/04/2023FrankHeatherAaronCharlie23/04/20239/04/2023 
523/04/2023CharlieAaronBarbaraDorcas9/04/2023  
630/04/2023HeatherFranklinEvanEvan30/04/20232/04/2023 
7Frank30/04/202316/04/2023 
8Franklin30/04/2023  
9Greta   
10Heather30/04/202316/04/2023 
11
12All Valslatest date2nd latest3rd latest
13Aaron23/04/202316/04/20232/04/2023
14Barbara23/04/20239/04/20232/04/2023
15Charlie23/04/20239/04/2023 
16Dorcas9/04/2023  
17Evan30/04/20232/04/2023 
18Frank16/04/2023  
19Franklin30/04/2023  
20Greta   
21Heather30/04/202316/04/2023 
Last 3
Cell Formulas
RangeFormula
G2:I10G2=IFERROR(AGGREGATE(14,6,data3[Date]*SIGN(SEARCH($F2,data3[Val1]&"|"&data3[Val2]&"|"&data3[Val3])),{1,2,3}),"")
G13:I21G13=IFERROR(AGGREGATE(14,6,data3[Date]*SIGN(SEARCH("|"&$F13&"|","|"&data3[Val1]&"|"&data3[Val2]&"|"&data3[Val3]&"|")),{1,2,3}),"")
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 1
Solution
Who would have thought I'd encounter such beautiful people on the internet today? Thank you both!
I wish I could have marked both as the solution.
 
Upvote 0
You are very welcome. Glad we could help. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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