To calculate fuel consumption, the system uses the data processed at the **Data preparation** and **Filtration** stages.

Fuel consumption by FLS (V_{consumed}) is calculated according to the formula:

**V**_{consumed} = V_{initial} − V_{final} + V_{filled}

where:

**V**_{initial}**V**_{final}**V**_{filled}

Two options and a special case are closely connected with the consumption calculation:

- the
**Replace invalid values with those calculated mathematically**option; - the
**Exclude drains from fuel consumption**option; - a case where the interval beginning or end divides a filling or a drain into parts.

## "Replace invalid values with those calculated mathematically" option

You can find this option in the **General settings** section of the sensor properties.

If this option is enabled and the system detects negative values of consumed fuel volume, they are replaced with the following values:

- mathematucally calculated ones, if a mathematical model is created;
- 0, if there is no mathematical model.

To create a basic mathematical model, you should just fill in the fields in the math consumption wizard. For a more accurate model, it is required to configure an ignition sensor, sensors of relative and absolute engine hours, and an engine efficiency sensor. For further information, see the expert article on math consumption.

The option only affects the data of the** Fuel consumed** and **Avg. fuel consumption** columns in reports.

## "Exclude drains from fuel consumption" option

You can find this option in the **General** section of the report template properties. It determines whether a fuel drain is considered as fuel consumption when calculating various indicators. This option allows excluding fuel consumption deviations related to the detected drains.

It may be necessary to disable the option in the cases where defuelling is authorized, for instance, when agriculture vehicles are filled by a refuelling tanker and the user wants to know the total turnover of the consumed fuel during the specified period of time.

## How a filling and a drain are detected if they are split by an interval

Let's analyze this case on the example of a fuel filling. For instance, the beginning of the interval divides the filling into two parts.

In this case, the second message in the interval is considered to be the starting message of the filling. This message shows that the fuel level has increased compared to the previous value. The first message serves as a reference and is used to determine the delta (d = V_{current} - V_{previous}) for the second. The delta for the first message can't be calculated because there is no previous message. The end message of the filling hasn't changed.

In this calculation, the filling volume is reduced compared to an undivided fillling, because the starting message of the filling is a later message.

The filling time may remain the same, as if the filling hadn't been split, or it may be shifted to a later time. This depends on whether the "undivided" filling time falls within the interval. If so, the filling time remains the same.