## Explanation

*Note: this example assumes that fuel is added to capacity at each gas stop, in order to calculate miles per gallon (MPG) based on the miles driven and fuel used since the last stop. In addition, this example keeps all data in an Excel Table called "data" to illustrate how Tables can make some formulas easier to maintain.*

The formula in E5 subtracts the mileage in the row above from mileage in the current row to calculate distance (miles driven) since the last gas stop:

```
[@Mileage]-SUM(C4)
```

The SUM formula is used only to prevent errors on the first row, where the row above contains a text value. Without SUM, the first row formula will return the #VALUE error. The SUM function however will treat the text in C4 as zero and prevent the error.

The formula in F5 calculates MPG (miles per gallon) by dividing miles driven by gallons used:

```
=[@Distance]/[@Gallons]
```

The result is formatted as a number with one decimal place.

### Summary stats

The formulas in I4:I6 calculate best, worst, and average MPG like this:

```
=MAX(data[MPG]) // best
=MIN(data[MPG]) // worst
=SUM(data[Distance])/SUM(data[Gallons]) // average
```

Because we are using an Excel Table to hold the data, these formulas will continue to show correct results as more data is added to the table.