Excel Formula to Return Previous Odometer Reading for a Fleet ID
Question details
The user needs to retrieve the most recent prior odometer reading for a specific fleet ID to assist with fuel-consumption calculations.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Calculating fuel consumption and managing fleet reporting using historical vehicle data.
- Observed behavior
- Needs a formula that looks up and fetches the last recorded odometer reading based on dates and fleet IDs before the current record.
Ensure your dataset is sorted by Fleet ID and then by Date in ascending order before applying any lookup formulas to guarantee accurate chronological results.
Use the XLOOKUP Formula in Excel
Use a specialized XLOOKUP function with multiple criteria to search for the most recent earlier record based on the Fleet ID and Date.
XLOOKUP is a powerful function that allows you to perform multi-criteria lookups and search backwards. By combining logical expressions, you can find the exact odometer reading from the previous date for the same vehicle.
Highlight your dataset, navigate to the 'Data' tab, and select 'Sort'. Sort the data first by 'Fleet ID' (A to Z) and then add a level to sort by 'Date' (Oldest to Newest).
In a new column next to your data, enter the formula: =IFERROR(XLOOKUP(1,(A:A=A2)*(B:B<B2),E:E,"",0,-1),""). This assumes column A is Fleet ID, B is Date, and E is Odometer Reading.
Modify the column letters (A, B, E) and row numbers (A2, B2) in the formula to exactly match your specific table layout and the starting row of your data.
Press Enter to get the result for the first row. Click the bottom-right corner of the cell and drag the fill handle down to apply the formula to the rest of the rows in your dataset.

Calculate Fleet Metrics Seamlessly with WPS Spreadsheet
WPS Spreadsheet offers powerful data management capabilities, including advanced lookup functions like XLOOKUP. This makes it incredibly easy to track fleet IDs, retrieve historical data, and calculate fuel consumption accurately without needing complex database software.
- 1. Open Fleet Data: Launch WPS Spreadsheet and open your vehicle fleet .xlsx or .csv data file.
- 2. Sort the Records: Use the Data tab to sort your records by Fleet ID and Date to prepare for the lookup.
- 3. Apply XLOOKUP: Use the multi-criteria XLOOKUP formula in an empty column to automatically fetch the previous odometer readings for your fuel calculations.

Frequently Asked Questions
Why is my XLOOKUP formula returning an error or blank?
Ensure your column references (like A:A for Fleet ID and B:B for Date) exactly match your data layout. If it returns blank, it means it is the first recorded date for that specific fleet ID, which correctly triggers the IFERROR blank output.
Can I use VLOOKUP instead of XLOOKUP for this?
Standard VLOOKUP cannot easily handle multiple criteria (matching both Fleet ID and an earlier Date) or search from the bottom up without complex helper columns. XLOOKUP or an INDEX/MATCH array formula is highly recommended for this scenario.
How do I calculate the fuel consumption after getting the previous reading?
Once you have the previous odometer reading in a new column, subtract the previous reading from the current odometer reading to get the total distance driven. Then, divide that distance by the amount of fuel added during the current fill-up.




