Results 1 to 2 of 2
  1. #1
    cafirf is offline Novice
    Windows 8 Access 2013
    Join Date
    Aug 2015
    Posts
    10

    Calculate Average Cost in Access

    Hi,



    I have a stock porfolio which I am trying to control using access instead of Excel. I have a table with the daily purchase and sale of stocks and I am trying to calculate the overall average cost of the entire portfolio. The calculation methodology is the same as for the Accounting Average Cost Inventory calculation



    I pasted a simple example of the calculation I want to make in Access:
    first 4 columns are from tb_movement - it has the daily portfolio purchase and sale
    [Notional] = [qtty]*[price]
    [Average Cost] - this is what I need to calculate. it is the sum of the notional divided by the sum of quantity for all purchase until the I have a sale, where the price should be the last average cost value multiplied by the quantity sold.



    Day Type of Transaction Qtty Price Notional Average Cost
    1 Purchase 5 130 650 130,00
    2 Purchase 10 108 1080 115,33
    3 Purchase 11 130 1430 121,54
    4 Purchase 13 130 1690 124,36
    5 Purchase 7 108 756 121,87
    6 Sale -11 121,87 -1340,57 121,87
    7 Purchase 15 127 1905 123,41
    8 Purchase 14 121 1694 122,88
    9 Purchase 8 118 944 122,34
    10 Sale -9 122,34 -1101,05 122,34


    hope it wasnīt too confusing, sorry iīm new to access and I canīt figure out how to do that.
    thank you!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Your example shows a running average. This is not simple to do in a query. It is relatively simple in a report because textbox has RunningSum property. Running calc is a common topic. Search forum or web.

    Your requirement to show in a Sale record the average value up to that point is like a 'year-to-date' summation. Review http://allenbrowne.com/subquery-01.html#YTD
    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.

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

Similar Threads

  1. Replies: 6
    Last Post: 06-05-2015, 03:08 AM
  2. Using a Do loop to calculate Average
    By pmpursley in forum Access
    Replies: 2
    Last Post: 01-17-2014, 06:04 PM
  3. Replies: 0
    Last Post: 12-01-2012, 05:35 PM
  4. Calculate the Average
    By Jerseynjphillypa in forum Queries
    Replies: 1
    Last Post: 06-18-2012, 03:26 PM
  5. Replies: 3
    Last Post: 06-23-2010, 07:33 AM

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