How to Find the Last Nonblank Value for an Employee in Excel
Question details
The user needs to retrieve the most recent or last nonblank balance for an employee from a dataset grouped by ID and separated by headers or blank rows.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Tracking employee balances (like PTO) over time when records are formatted in grouped lists rather than a continuous flat table.
- Observed behavior
- The goal is to extract the latest nonblank record for each employee effectively, either by restructuring the dataset or using advanced lookup functions.
Review your dataset structure. Consider whether you can restructure the data into a standard flat table (e.g., Employee ID, Date, Balance) before applying formulas, as this significantly simplifies calculations and prevents errors caused by blank rows.
Restructure Data and Summarize with a PivotTable
The most robust approach is to normalize your data into a single flat table rather than keeping separate formatted groups per employee.
Keeping track of employee balances in separate, visually formatted groups makes data analysis difficult. By consolidating everything into one large table with three columns (Employee ID, Hours, and Date), you can easily calculate current balances.
Set up a single table with three headers: Employee ID, Date, and PTO Balance (or Hours).
Input the starting balance for each employee as a positive number. Below those, log the number of hours used by each employee over time as a negative number.
Select your entire data range, go to the Insert tab, and click PivotTable. Choose to place it on a new worksheet.
In the PivotTable Fields pane, drag 'Employee ID' to the Rows area, and 'PTO Balance' to the Values area. The PivotTable will automatically sum the positive and negative values to show the current balance for each employee.

Find the Last Match Using XLOOKUP
If your data is already in a continuous list, use the XLOOKUP function to search from the bottom up and return the latest entry.
Handle Grouped Layouts with SCAN (Microsoft 365)
If you cannot alter the original report's grouped layout, use advanced dynamic array functions to identify employee blocks.
Track Employee Balances Easily with WPS Spreadsheet
WPS Spreadsheet provides powerful functions like XLOOKUP, FILTER, and PivotTables to seamlessly manage and retrieve employee data. It offers a familiar interface and is fully compatible with Microsoft Excel formats.
- 1. Open your data in WPS Spreadsheet: Launch WPS Office, open your .xlsx file, and view your employee dataset.
- 2. Standardize your layout: Organize your data into continuous columns without blank separating rows to ensure formula accuracy.
- 3. Apply formulas or PivotTables: Use the XLOOKUP function to search from the bottom up, or insert a PivotTable from the Insert tab to automatically summarize employee balances.

Frequently Asked Questions
Why is my XLOOKUP returning the first value instead of the last?
By default, XLOOKUP searches from the first row to the last row. To find the last nonblank value, you must set the `search_mode` argument (the 6th parameter in the formula) to `-1`, which instructs it to search from last to first.
Can I find the last nonblank value using VLOOKUP?
VLOOKUP does not have a built-in parameter to search from the bottom up. To achieve this with VLOOKUP, you would need to sort your data in descending order by date first. Alternatively, it's better to use XLOOKUP or an INDEX/MATCH array formula.
What does data normalization mean in Excel?
Normalizing data means structuring it into a continuous, flat table (e.g., columns for Employee ID, Date, and Amount) without blank rows, merged cells, or visual block separations. This standard format allows PivotTables and lookup functions to work reliably.




