dbTalk Databases Forums  

Simple Calculation gone awry...

comp.databases.filemaker comp.databases.filemaker


Discuss Simple Calculation gone awry... in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
rocktour@earthlink.net
 
Posts: n/a

Default Simple Calculation gone awry... - 06-04-2005 , 08:01 PM






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


Reply With Quote
  #2  
Old   
Helpful Harry
 
Posts: n/a

Default Re: Simple Calculation gone awry... - 06-07-2005 , 01:08 AM






In article <1117930266.485535.225680 (AT) g44g2000cwa (DOT) googlegroups.com>,
rocktour (AT) earthlink (DOT) net wrote:

Quote:
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
Your problem is that you can't use a Summary field within a Calculation
(field or script) like that. You get peculiar results because the
Summary field is only properly calculated when in Preview mode.

You don't say what the how you're grouping records, eg. by day, by car,
etc. or if it is just ALL records in the database, but the best method
is to define a relationship to group the records and then use the Sum
function to obtain the total of FuelGallons for the group. That way
your calculations become:

Total Miles = EndMileage - BeginningMileage

TotalGallons = Sum(Relationship::FuelGallons)

Average MPG = TotalMiles / TotalGallons

ALTHOUGH, it does depend on where you're getting EndMilage and
BeginningMilage from. If those are being obtained fomr the current
record, then using the TotalGallons will give you an incorrect fuel
consumption.



Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships ;o)


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.