# Simple Calculation gone awry...

This topic is 7008 days old. Please don't post here. Open a new topic instead.

## Recommended Posts

• Newbies

I am trying to automatically figure miles per gallon.

I have several records (state line crossings) of which some contain fuel purchases for that state. I have created a trailing grand summary part which contains totals of fuel purchased (gallons, etc) which works fine. I have also created a total miles field which is a calculation of the EndingMileage-StartingMileage fields. The AverageMPG field contains a calculation of TotalGallons/TotalMiles which also works fine.

Here is the problem. If I enter a fuel purchase in the first record only, it places the correct MPG in the AverageMPG field. If I do not enter a purchase in the first record but enter purchases in other records it enters a ? in the field. If I enter a purchase in the first record and also other records, it enters the AverageMPG as if the first record was the only fuel purchased thereby ignoring the other fuel purchases.

Fields...

TotalMiles Calculation EndingMileage-BeginningMileage

TotalGallons Summary =Total of FuelGallons (running)

AverageMPG Calculation Unstored =TotalMiles/TotalGallons

Thanks in advance for the help,

Charlie

##### Share on other sites

I think there may be some confusion here in the combining of calculation fields with summary fields. The TotalMiles calculation operates on each record individually, while the TotalGallons summary includes all records in the found set (or subsummary part). Therefore, the AverageMPG calculation is the current record's mileage divided by the running total of FuelGallons for the found set (or subsummary, when in Preview Mode).

I think what you need is another summary field called Total of TotalMiles, defined to be a running total of the TotalMiles calculation. Use this in your AverageMPG calculation, instead of TotalMiles.

##### Share on other sites

This topic is 7008 days old. Please don't post here. Open a new topic instead.

## Create an account

Register a new account