Calculation Issues

How to Calculate Truck Fuel Consumption from Mileage Records in Excel

Emma BrownEmma Brown Nov 10, 2026 871 views

Question details

The user wants to calculate the fuel consumption for trucks based on the latest and previous mileage records and diesel quantities.

How to Calculate Truck Fuel Consumption from Mileage Records in Excel
Product
Excel
Device & OS
not provided
Scenario
Tracking and calculating truck fuel efficiency over time using mileage and diesel fill-up data.
Observed behavior
Data is currently being added in new columns, making it difficult to calculate the difference between the latest and previous mileage readings.
Before you start

Ensure your mileage and fuel data is organized consistently. It is highly recommended to back up your current spreadsheet before restructuring your data layout.

Solution 1Recommended

Restructure Data into an Excel Table and Use FILTER Formulas

Convert your column-based data entry into a row-based Excel Table to easily calculate fuel consumption using dynamic formulas.

Storing data in rows rather than continually adding new columns makes your dataset much easier to filter, expand, and analyze.

By using an Excel Table, you can leverage structured references and dynamic array formulas like FILTER to automatically find previous records for each specific truck without manual updates.

1
Create a Standardized Table

Set up a new sheet with column headers: Truck No., Date, Mileage (KM), and Diesel Liters. Enter each new record as a new row under these headers. Select your data and press Ctrl+T to format it as an Excel Table.

2
Calculate Previous Mileage

Add a column named 'Previous KM'. Use a formula combining INDEX and FILTER to find the last recorded mileage for the same truck before the current date: =IFERROR(INDEX(FILTER([Mileage No]:[KM],([Date]<[@Date])*([Truck No.]=[@[Truck No.]])),1,5),"") (adjust the column index '5' based on your actual table structure).

3
Calculate Previous Diesel Liters

Add a column named 'Previous Diesel Ltrs'. Use a similar formula to fetch the previous diesel amount: =IFERROR(INDEX(FILTER([Mileage No]:[KM],([Date]<[@Date])*([Truck No.]=[@[Truck No.]])),1,4),"").

4
Calculate Fuel Consumption

Add a final column for 'Consumption'. Subtract the previous mileage from the current mileage, then divide by the previous diesel liters: =IFERROR(([@KM]-[@[Previous KM]])/[@[Previous Diesel Ltrs]],"").

Restructure Data into an Excel Table and Use FILTER Formulas
Data Management Tip: Using an Excel Table ensures that your formulas automatically apply to any new rows you add in the future, saving you from copying formulas manually.
Manage Fleet Data Efficiently

Calculate Fuel Consumption Easily with WPS Spreadsheet

WPS Spreadsheet provides full support for dynamic array formulas like FILTER and structured table references, making it the perfect tool to track and calculate your fleet's fuel consumption.

  1. 1. Open your data in WPS Spreadsheet: Launch WPS Office and open your existing mileage tracking workbook.
  2. 2. Format as Table: Select your data range, go to the 'Home' tab, and click 'Format as Table' to convert your data into a structured format.
  3. 3. Apply the Formulas: Enter the FILTER and IFERROR formulas in the respective columns to automatically calculate the previous mileage and fuel consumption.
  4. 4. Analyze and Save: Review the calculated consumption rates and save your document in the standard .xlsx format for easy sharing.
Fully compatible with Microsoft Excel formulas and .xlsx formatsSupports advanced functions like FILTER, INDEX, and IFERRORBuilt-in table formatting for easy data managementFree and lightweight alternative for everyday data analysis
microsoft office alternative - wps office

Frequently Asked Questions

Why is it better to store data in rows instead of columns?

Storing data in rows (a tabular format) is the standard for database management in spreadsheet software. It allows you to easily use built-in features like PivotTables, filtering, sorting, and dynamic array formulas, which become very difficult to manage when data grows horizontally across columns.

What does the IFERROR function do in the fuel consumption formula?

The IFERROR function catches any errors that occur during the calculation—such as dividing by zero if a previous diesel amount is missing, or if it is the very first record for a truck—and returns a blank cell instead of an error code like #DIV/0!.

Can I use VLOOKUP instead of FILTER to find the previous mileage?

VLOOKUP is not ideal here because you need to match multiple criteria simultaneously (both the specific Truck Number and a Date that is prior to the current row's date). The FILTER function, or a combination of INDEX and MATCH with array criteria, is much better suited for multi-criteria lookups.