Home » excel » Return a date based on criteria in excel

# Return a date based on criteria in excel

Questions:

I have a table of `athlete names`, `training sessions` and `completion dates`.

From this table, I want to extract the most recent dates (excluding the current date) that a specific athlete completed a specific session.

So far my formula is as follows:

``````= IF (MATCH (\$AC27&\$AD27
,'Data'!\$A\$2:\$A\$2000 & 'Data'!\$BS\$2:\$BS\$2000
, 0
)
,MAX(('Data'!\$B\$2:\$B\$2000 < \$AE\$1) * 'Data'!\$B\$2:\$B\$2000)
,
)
``````

where

``````'Data'!        - Threshold Efforts Data Entry sheet
\$AC\$27         - specific athlete name
\$A\$2:\$A\$2000   - lookup array for athlete names
\$BS\$2:\$BS\$2000 - look up array for sessions
\$B\$2:\$B\$2000   - look up array for dates
\$AE\$1          - the current date
``````

The formula works, however it returns the most recent date, rather than the most recent date matched for the athlete name and session.

Where have I gone wrong ?

This works for me.

``````=MAX(IF(\$A\$5:\$A\$12=D5,IF(\$B\$5:\$B\$12<\$B\$1,\$B\$5:\$B\$12)))
``````

It’s an array function, so click in the cell and press ctrl + shift + enter. I tried to follow your cell references. You can use a combination of `SUMPRODUCT` and `MAX`:
``````=SUMPRODUCT(MAX((A1:A13=AC27)*(BS1:BS13=AD27)*B1:B13)) 