Lookup based on 2-way matching with an embedded date condition

chris_bosten

New Member
Joined
Aug 21, 2024
Messages
15
Office Version
  1. 365
Platform
  1. Windows
Dear sir/madam

I am making a training matrix and am struggling with a formula.

I have one tab called "training module entry" where trainers can input when a piece of training has been completed.
A B C D E F G H

Date of TrainingEmployee NameEmployee IDModule NameModule IDFrequencyTrainerValid to
28/11/2023X1EID0001Manual HandlingPATR039AnnualH28/11/2024
28/11/2024X2EID0006Manual HandlingPATR039AnnualH28/11/2025
28/11/2024X3EID0004Manual HandlingPATR039AnnualH28/11/2025
28/11/2024X4EID0008Manual HandlingPATR039AnnualH28/11/2025
28/12/2023X5EID0050Manual HandlingPATR039AnnualH28/12/2024
28/11/2024X6EID0032Yard Safety WaterswallowsPATR025AnnualH28/11/2025
28/11/2024X7EID0012Technosys SSoWPATR012One-offHNo End Date

Depending on which module has been selected, the valid to date will adjust.

I then have a second tab for the training matrix:
A B C D E F G H I J K L M N O P Q

Mixing and PackingMixing and Packing SpecialismTraining Valid To

LOTOSilo 8 Bagger SSoWSilo 2 SSoWSilo 10 SSoWAir Packer SSoWBoone Mixer 1 SSoWBoone Mixer 2 SSoWHeating Plant SSoWSilo 9 SSoWMIS BaggingMIS MixingTechnosys SSoWPowders Shift RoutineYard Safety WaterswallowsManual Handling
NameEmployee IDPATR001PATR002PATR003PATR004PATR005PATR006PATR007PATR008PATR009PATR010PATR011PATR012PATR013PATR025PATR039
X5EID0050No RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo Record28/12/2024
X6EID0008No RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo Record28/11/2025
X7EID0004No RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo Record28/11/2025

I want the cells in this matrix to return a valid to date based on a 2-way match of employee ID and module ID. If no match can be found I want it to return "No Record." I have done this in cell Q4 with the following formula:

=FILTER('Training Module Entry'!$H$2:$H$10000,('Training Module Entry'!$C$2:$C$10000='M&P Matrix'!B4)*('Training Module Entry'!$E$2:$E$10000='M&P Matrix'!Q3),"No Record").

I have 2 problems. Firstly, if an individual with a unique employee ID has multiple training records uploaded for the same training module, I want the expiry date to be based on the module entry with the most recent "date of training" date.

Secondly, if the expiry date is greater than a month after today's date, I want the cell to return "expired"

Can you help?

Best wishes
Chris
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
I have done a workaround - so only answer this if you fancy it!

Best wishes
Chris
 
Upvote 0
I have a simpler problem. I'm highlighting duplicate values in a column, but if the cells are blank I don't want any highlight - how do I achieve this in conditional formatting?
1733308401835.png
 
Upvote 0
You might want to make that a separate thread.
In relation to your first thread the "Expired" logic seems to be back to front. Surely if the Valid to date is greater than today is hasn't expired.

This is my thinking on it:

20241204 Filter Max Date chris_bosten.xlsx
ABCDEFGHIJKLMNOPQ
1
2LOTOSilo 8 Bagger SSoWSilo 2 SSoWSilo 10 SSoWAir Packer SSoWBoone Mixer 1 SSoWBoone Mixer 2 SSoWHeating Plant SSoWSilo 9 SSoWMIS BaggingMIS MixingTechnosys SSoWPowders Shift RoutineYard Safety WaterswallowsManual Handling
3NameEmployee IDPATR001PATR002PATR003PATR004PATR005PATR006PATR007PATR008PATR009PATR010PATR011PATR012PATR013PATR025PATR039
4X5EID0050No RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo Record28/12/2024
5X6EID0008No RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo Record28/11/2025
6X7EID0004No RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo Record28/11/2025
7X1EID0001No RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo Record28/11/2024
8X9EID0012No RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo RecordNo Record28/11/2025No RecordNo RecordNo Record
M&P Matrix
Cell Formulas
RangeFormula
C4:Q8C4=LET(arrFltr,FILTER('Training Module Entry'!$H$2:$H$10000,('Training Module Entry'!$C$2:$C$10000=$B4)*('Training Module Entry'!$E$2:$E$10000=C$3),"No Record"), ValidTo,IF(COUNTA(arrFltr)>1,MAX(arrFltr),arrFltr), IF(ISNUMBER(ValidTo),IF(ValidTo<(EDATE(TODAY(),-1)),"Expired",ValidTo),ValidTo))
 
Upvote 0
=LET(arrFltr,FILTER('Training Module Entry'!$H$2:$H$10000,('Training Module Entry'!$C$2:$C$10000=$B4)*('Training Module Entry'!$E$2:$E$10000=C$3),"No Record"), ValidTo,IF(COUNTA(arrFltr)>1,MAX(arrFltr),arrFltr), IF(ISNUMBER(ValidTo),IF(ValidTo<(EDATE(TODAY(),-1)),"Expired",ValidTo),ValidTo))
Hi, yes you were right about that logic, need my morning coffee!
 
Upvote 0
Hi Alex, I gave it a go but found that an entry that should have returned "expired" was showing as "no record" - which cell should I copy that formula into?
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,703
Members
452,938
Latest member
babeneker

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