+ Reply to Thread
Results 1 to 12 of 12

Formula not matching to correct date in price history

  1. #1
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,394

    Formula not matching to correct date in price history

    Can't work out formula to find the relevant price for a given date.

    Col A on attached lists range of products. Col B lists the dates of price raises. Col C lists the relevant price at each increase.

    Formula in Col G

    {=INDEX($C$1:$C$31, MATCH(E3&F3, $A$1:$A$31&$B$1:$B$31,0))}

    should find the price in Col C for the product in Col A matching E3, at the date in Col B that covers the date in F3, but setting it as "exact" match generates an error between dates, and setting it as more or less than generates only the orignal value.

    Col J shows how it should work..

    Any pointers or solutions accepted gratefully as ever.

    Ochimus
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    02-07-2013
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2007
    Posts
    290

    Re: Formula not matching to correct date in price history

    Hi Ochimus,

    Your formula is working fine as it should.
    Error values are because there is no matching values, for example there is no 15-Dec-2015 for Product 1.

    Similar result can be achieved with simple regular SUMIFS:
    =SUMIFS($C$2:$C$31,$A$2:$A$31,E3,$B$2:$B$31,F3)

    Regards,
    Khalid

  3. #3
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,394

    Re: Formula not matching to correct date in price history

    Khalidngo,

    Appreciate the quick response,m but your approach does not work either.

    If you apply the SumIfs to Row 3, it finds the pricxe at £1.00, as did the Index Match,

    But if you copy it to row 4, the value for a sale on 15 Dec should be the price that started on 1 December, because the price does not go up to £1.02 until 1 Jan.

    Your "Sumifs" formula results in a Zero, not £1.00

    Ochimus

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,145

    Re: Formula not matching to correct date in price history

    Sort table by Product/Date in ascending order

    then try

    =INDEX($C$1:$C$31,MATCH($F3,OFFSET($B$1,MATCH($E3,$A$2:$A$31,0), 0,COUNTIF($A$2:$A$31,$E3),1),1)+MATCH($E3,$A$2:$A$31,0))
    Last edited by JohnTopley; 12-04-2016 at 05:53 PM.

  5. #5
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,394

    Re: Formula not matching to correct date in price history

    John,

    Interesting approach, although was hoping to get it to work where the End User can add any product, effective date and new price on the next free row of the sheet.

    (To simplify the issue, the sample gives every product in the range an increase on the same day each month, and keeps them in the same "running order".)

    Ochimus

  6. #6
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,899

    Re: Formula not matching to correct date in price history

    Or try this ...

    =LOOKUP(10^10,$C$1:$C$31/($A$1:$A$31=$E3)/($B$1:$B$31<=$F3))

  7. #7
    Forum Contributor
    Join Date
    08-25-2014
    Location
    Pennsylvania, US
    MS-Off Ver
    Windows '16
    Posts
    165

    Re: Formula not matching to correct date in price history

    Ochimus, as long as John's response solves your problem, here it is edited to allow a full million rows of data.

    =INDEX(C:C,MATCH($F3,OFFSET($B$1,MATCH($E3,A:A,0), 0,COUNTIF(A:A,$E3),1),1)+MATCH($E3,A:A,0))

    (1) I cringe at posting a formula with whole column references in it, but Excel has gotten better at handling them.
    (2) Don't use this if recalculation performance is a serious consideration. Both whole column refs and the use of OFFSET may slow things down.

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,145

    Re: Formula not matching to correct date in price history

    Phuocam has given you the solution: I wasn't too pleased with my own and knew there must be simpler way.

  9. #9
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,394

    Re: Formula not matching to correct date in price history

    Thanks everyone,

    Phuocam's solution works perfectly, but have not seen that structure before.

    Can follow the column and cell references, but what is the "10^10" lookup value?

    Ochimus

  10. #10
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,145

    Re: Formula not matching to correct date in price history

    10^10 is just a large number which ensures that no value will exceed this amount so LOOKUP finds the first value which less than or equal to 10^10.

  11. #11
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,394

    Re: Formula not matching to correct date in price history

    John,

    Now clear.

    Must admit to never being an "aficionado" of LookUps, preferring Index/Match as the approach, but it came up trumps on this issue.

    Thanks again to everyone for the prompt help, and can now mark this as "Solved"

    Ochimus

  12. #12
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,394

    Re: Formula not matching to correct date in price history

    Sorry - message duplicated for some reason! Hopefully someone further up the Food Chain can remove this altogether?
    Last edited by Ochimus; 12-06-2016 at 02:12 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Logic formula needed to look up a value and compare dates to return correct price
    By tomm8810 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-18-2017, 11:37 PM
  2. [SOLVED] macro getting price history online
    By knebelcm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-31-2016, 05:32 PM
  3. [SOLVED] Price search history extracting
    By makinmomb in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-01-2014, 08:13 AM
  4. Replies: 3
    Last Post: 01-03-2013, 12:32 AM
  5. [SOLVED] Matching Data to Supply Correct Date
    By MegKerr in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-05-2012, 09:00 PM
  6. Replies: 3
    Last Post: 07-17-2012, 03:34 AM
  7. Excel 2007 : Linking columns to get a correct price
    By roofix australia in forum Excel General
    Replies: 1
    Last Post: 07-04-2011, 09:39 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1