Function Problems

Excel Formula to Return Previous Odometer Reading for a Fleet ID

Bushra ParveenBushra Parveen Oct 12, 2026 868 views

Question details

The user needs to retrieve the most recent prior odometer reading for a specific fleet ID to assist with fuel-consumption calculations.

How to Return the Previous Odometer Reading for a Fleet ID in Excel
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.
Before you start

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.

Solution 1Recommended

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.

1
Sort Your Data

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).

2
Enter the XLOOKUP Formula

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.

3
Adjust Cell References

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.

4
Apply to Remaining Rows

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.

Use the XLOOKUP Formula in Excel
Using Microsoft Access: If you are managing your fleet data in Microsoft Access instead of Excel, you cannot use XLOOKUP. You will need to use a self-join or a correlated subquery in SQL to find the latest earlier odometer reading for the same fleet ID.
Manage Fleet Data Efficiently

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. 1. Open Fleet Data: Launch WPS Spreadsheet and open your vehicle fleet .xlsx or .csv data file.
  2. 2. Sort the Records: Use the Data tab to sort your records by Fleet ID and Date to prepare for the lookup.
  3. 3. Apply XLOOKUP: Use the multi-criteria XLOOKUP formula in an empty column to automatically fetch the previous odometer readings for your fuel calculations.
Fully compatible with Microsoft Excel formulas and .xlsx filesSupports advanced lookup functions like XLOOKUP, VLOOKUP, and INDEX/MATCHLightweight and fast performance, even when processing large fleet datasetsFree to use with a familiar, user-friendly interface for seamless migration
microsoft office alternative - wps office

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.