Results 1 to 4 of 4
  1. #1
    aetedford is offline Novice
    Windows 10 Access 2007
    Join Date
    Jul 2018
    Posts
    6

    Query to get most recent price between dates

    I marked a previous thread because I made it way too complicated for what I am looking for.



    I have a table below that I need to get a start price and end price for each PART for dates between 1/1/18 and 3/31/18.

    For example, PART 1000 would have a start price of $3.85 and an end price of $4.12 for a % change of 7.01%
    I'd like to have the resulting query show PART, 1/1/18 PRICE, 3/31/18 PRICE, and % CHANGE

    If there is no price for 1/1/18 (part 2000) it wouldn't calculate % CHANGE.

    PART
    DATE
    PRICE
    1000 1/1/2014 $ 4.00
    1000 4/1/2017 $ 3.85
    1000 3/12/2018 $ 4.12
    1003 1/1/2018 $ 0.50
    1003 1/2/2018 $ 0.75
    1003 3/31/2018 $ 0.88
    2000 2/12/2018 $ 4.12
    2050 12/31/2017 $ 3.33
    2050 4/1/2018 $ 3.00


    Any assistance is greatly appreciated. Thanks

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,973
    Just to clarify the start and end prices for each part are
    1000: $3.85, $4.12
    1003: $0.5, $0.88
    2000: N/A, $4.12
    2050: $3.33, $3.00

    In each case, it uses the last price on or before the specified dates????
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    aetedford is offline Novice
    Windows 10 Access 2007
    Join Date
    Jul 2018
    Posts
    6
    Item 2050 would be $3.33 and $3.33 because the new price kicks in after 3/31/18. But, yes, you are correct with each case.

    Thank you

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,973
    Ah yes. I live in the UK so misread the last date.
    I think the will either need several queries or the use of subqueries.

    Suggest you upload a cut down db with some more sample data to make it easier for someone to assist

    Is this something you will need to do every quarter year.
    If so, it may be easier to create a new denormalised table with all the required fields and populate that each quarter
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

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

Similar Threads

  1. Replies: 6
    Last Post: 07-05-2018, 09:15 AM
  2. Find 2 most recent dates
    By cmiley in forum Queries
    Replies: 17
    Last Post: 01-19-2017, 04:57 PM
  3. Need to pull query for 2 Status with recent and prior dates
    By undefatedskillz26 in forum Queries
    Replies: 7
    Last Post: 12-23-2014, 03:33 PM
  4. Replies: 5
    Last Post: 10-09-2013, 02:37 PM
  5. Replies: 5
    Last Post: 07-29-2011, 12:55 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