Excel Formula to Return a Value Only for the Latest Date
Question details
The user needs a spreadsheet formula that evaluates a dataset and outputs a specific calculation or result only on the row that contains the most recent date for a matching lookup value, leaving all earlier date rows blank.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Filtering and analyzing a dataset where multiple entries exist for the same identifier, and a calculation should only be performed on the latest entry.
- Observed behavior
- The user requires a conditional formula to single out the maximum date per group and execute a specific formula exclusively on that row.
Ensure your dataset is organized with clear columns for the lookup value (e.g., ID or Name) and the date. Verify that the date column contains valid date formats rather than plain text, and that your spreadsheet software supports the MAXIFS function.
Use the IF and MAXIFS Functions
Combine the IF function with MAXIFS to check if the current row's date matches the maximum date for a specific lookup value, returning the result only if it matches.
The MAXIFS function is designed to return the maximum value in a range that meets one or more criteria. By embedding it within an IF statement, you can compare the date in the current row to the maximum date for that specific group. If they match, the formula executes your desired calculation; otherwise, it returns a blank cell.
Click on the cell in the first data row of your result column (for example, cell A6) where you want the formula to output the value.
Type the formula: =IF(AA6=MAXIFS(AA$6:AA$10000,O$6:O$10000,O6),($AP$1-AA6)/AC6,"") into the formula bar. In this example, AA represents the date column, O is the lookup value column, and ($AP$1-AA6)/AC6 is the custom calculation you want to perform.
Ensure that your range references for the MAXIFS function (like AA$6:AA$10000 and O$6:O$10000) are locked using the dollar sign ($) so they do not shift when you drag the formula down.
Press Enter to apply the formula. Then, click the small square at the bottom-right corner of cell A6 and drag it down to fill the formula through the rest of your dataset.

Easily Manage Advanced Formulas in WPS Spreadsheet
WPS Spreadsheet fully supports advanced logical and statistical functions, including IF and MAXIFS. It provides a smooth, fast experience for processing complex formulas over large datasets without lagging.
- 1. Open your dataset in WPS Spreadsheet: Launch WPS Office and open your .xlsx or .csv file containing the lookup and date values.
- 2. Input the conditional formula: Select the target cell and type your =IF(..., MAXIFS(...)) formula just as you would in Excel.
- 3. Utilize formula prompts: Take advantage of WPS Spreadsheet's intelligent autocomplete to select ranges and structure the syntax effortlessly.
- 4. Drag to fill: Double-click the fill handle in the bottom right of the active cell to instantly apply the calculation to your entire column.

Frequently Asked Questions
What if my version of Excel doesn't support the MAXIFS function?
If you are using an older version that lacks MAXIFS, you can use an array formula instead. Enter =IF(AA6=MAX(IF(O$6:O$10000=O6, AA$6:AA$10000)), your_calculation, "") and press Ctrl+Shift+Enter to evaluate it as an array formula.
Why is the formula returning a blank cell for every row?
This usually happens if your dates are formatted as text rather than numerical date values, or if there are leading/trailing spaces in your lookup values. Ensure the data formats in your lookup column and date column match exactly.
How can I return a value for the earliest date instead of the latest?
To return a value for the earliest date, simply replace the MAXIFS function in your formula with the MINIFS function. MINIFS will identify the smallest (oldest) date for the matching lookup value.




