Results 1 to 3 of 3
  1. #1
    slavrenz is offline Novice
    Windows 8 Access 2013
    Join Date
    Mar 2015
    Posts
    5

    How to calculate a value in one table row from another row?

    Sorry if this is in the wrong forum; I am relatively new to Access, and wasn't sure if this is query-related or not. I am trying to set up a database in Access 2013 for vehicle maintenance and fuel tracking. I have a table called "fuel" where I enter fuel purchases (including mileage at fillup, total cost, total gallons, etc.)



    I want to have a field in this table called "MPG". This field, for a given row, will take the number from the "mileage" field and find the total miles traveled by looking back through the previous rows and finding the next highest mileage. It will then divide this difference by the number entered in the "gallons" field for the current row, and this will give the number for the "MPG" field.

    I'm sure I'm making this sound way more complicated than it is - I'm pretty sure everyone knows how to do an MPG calculation - and I could do it with Excel by just using VLOOKUP or INDEX/MATCH (or even just by assuming that all fuel entries are chronological and looking back at the previous row). Just not sure how to accomplish this in Access!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    slavrenz is offline Novice
    Windows 8 Access 2013
    Join Date
    Mar 2015
    Posts
    5
    Ah, that looks like exactly what I need...thanks for the quick response!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 8
    Last Post: 02-27-2014, 01:28 PM
  2. Replies: 7
    Last Post: 05-02-2013, 11:14 PM
  3. Is it possible to calculate in a table?
    By shafiq037 in forum Access
    Replies: 1
    Last Post: 05-02-2013, 10:08 PM
  4. Replies: 1
    Last Post: 09-07-2011, 02:42 AM
  5. Replies: 1
    Last Post: 08-17-2011, 11:13 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums