Results 1 to 3 of 3
  1. #1
    Kaloyanides is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Jan 2015
    Location
    Arlington, MA
    Posts
    51

    Calculation based on Query Row or Record Location

    I'm trying to do a series of calculations in an access query.



    It's to calculate the % change of stock prices.

    For each stock, there are almost 4,000 records. It's the closing price for each day going back to 1999.

    Table
    Date Symbol Price
    11/18/1999 AA 41.17

    I'm trying to create the following for Query Record each symbol:

    Symbol 5 Day %Change 10 Day %Change 30 Day %Change 60 Day %Change 90 Day %Change 6 Mo %Change 1 Yr %Change 2 Yr %Change 3 Yr %Change 4 Yr %Change 5 Yr %Change etc....

    The Query needs to calculate the % change between the most recent Previous Close Price and the preceding 5th record, 10th record, 30th record, 60th record, etc...

    I hope I'm explaining correctly.

    I can't figure out how to write the following formula:
    5DayChange : =([PreviousClose]-[5 Records Back in the Table)/ABS([5 Records Back in the Table)
    10DayChange : =([PreviousClose]-[10 Records Back in the Table)/ABS([10 Records Back in the Table)

    Or, should I be trying to do this by defining a specific date to use in each calculation?

    Thx in advance!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    You can't. You must calc the on day X in 1 qry.
    then another qry for day X-5
    another qry , day x-10

    but not record, unless they are sequentually numbered
    note: a record cannot see its neighbor.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Options for each record to pull value from another record of same table:

    1. multiple queries ranman describes

    2. nested subquery - review http://allenbrowne.com/subquery-01.html#AnotherRecord

    3. domain aggregate function - DLookup, DMax, DMin
    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: 2
    Last Post: 09-23-2014, 02:15 PM
  2. Replies: 2
    Last Post: 02-02-2014, 07:19 PM
  3. Record selection based on calculation
    By WEJ in forum Programming
    Replies: 5
    Last Post: 05-30-2013, 01:05 PM
  4. Replies: 0
    Last Post: 04-18-2011, 01:01 PM
  5. duplicate record based on calculation
    By Coolpapabell in forum Queries
    Replies: 4
    Last Post: 08-06-2009, 07:53 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