+ Reply to Thread
Results 1 to 12 of 12

index match - 2 criteria, one approximate

  1. #1
    Registered User
    Join Date
    04-11-2015
    Location
    London
    MS-Off Ver
    MS Office 2010
    Posts
    6

    index match - 2 criteria, one approximate

    Hello All,

    This forum has helped me a lot to find solutions - however a bit stumped on this one.

    Attached is a sheet with Country, Currency, effective date and operational rate.

    I was looking to do an index match to find the exchange rate for a given currency and trade date (find the previous closest effective date - if this does not exist then find the closest date after the trade date. (Cells G5:I5)

    I something like this formula to get the closest previous date - but it does not take into account the currency code:
    =INDEX(E6:E19999, MATCH(MIN(IF(D6:D19999-H6<=0, D6:D19999-H6, "")), D6:D19999-H6, 0))


    Thanks!
    Attached Files Attached Files

  2. #2
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: index match - 2 criteria, one approximate

    All the Effective Dates in your workbook are TEXT dates and have to be changed to real Excel Dates. Select column D and use Text to Columns, Delimited, choose Date, MDY, and click Finish. This will convert all the dates to real dates.

    Array Enter (Ctrl + Shift + Enter) this formula in H6:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Array Enter this formula in I6:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    This will give you the last Effective Date for the currency in G6 and the Operational Rate for that date.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  3. #3
    Registered User
    Join Date
    04-11-2015
    Location
    London
    MS-Off Ver
    MS Office 2010
    Posts
    6

    Re: index match - 2 criteria, one approximate

    Thanks for your reply- In column H6 i already have a list of trade dates. I wanted to to get the closest (last) corresponding operational rate. E.g. For a trade on 17 Dec 2014 with currency CHF (I would like a formula that would find the 15 dec CHF rate of 0.969)

    In case the previous date was not available (e.g. for the currency Code SAR, if there is a trade date of 17 Dec 2014, the SAR only has one effective date of 1 april 2015 with rate 3.751) so ideally the formula can pick this one even if it is not the closest previous date.

  4. #4
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: index match - 2 criteria, one approximate

    So, you can pick any date, not necessarily the last but any date at all, and you want the closest one if it isn't exact. Is that correct?

  5. #5
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: index match - 2 criteria, one approximate

    This might require VBA to solve. Right now, I'm just trying to get my head around what you need.

  6. #6
    Registered User
    Join Date
    04-11-2015
    Location
    London
    MS-Off Ver
    MS Office 2010
    Posts
    6

    Re: index match - 2 criteria, one approximate

    yes exactly right. pick any date, and the formula picks the closest previous date if it exists for the currency code in question.

  7. #7
    Registered User
    Join Date
    04-11-2015
    Location
    London
    MS-Off Ver
    MS Office 2010
    Posts
    6

    Re: index match - 2 criteria, one approximate

    essentially certain currencies have been traded in the market on different dates (trade dates) and i would like to compare them to the nearest previous UN rate).

    initially i had done an index match based on month year and currency. But some currencies have a couple of different rates in one month.

  8. #8
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: index match - 2 criteria, one approximate

    All dates are not in standard date of Excel format, so I have to try to solve it inside the formula, so sorry for such huge formula!

    At least, try to delete cell H6, then format cell as "mm/dd/yyyy", the enter below array formula in I6:

    Please Login or Register  to view this content.
    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.
    Attached Files Attached Files
    Quang PT

  9. #9
    Registered User
    Join Date
    04-11-2015
    Location
    London
    MS-Off Ver
    MS Office 2010
    Posts
    6

    Re: index match - 2 criteria, one approximate

    Long formula but its working well! thank you so much!

  10. #10
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: index match - 2 criteria, one approximate

    Nice formula Quan PT

    Here is your example file with Quan PT's formula simplified by using real dates in column D thus eliminating the need to convert the dates for each row.

    The dates in column D were converted to real Excel dates by selecting column D and the using Text to Columns, Delimited, Next, Next,DATE (MDY), Finish. Then with the column D selected, format the column as dd/mm/yyyy.

    The formula is then shortened to:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    04-11-2015
    Location
    London
    MS-Off Ver
    MS Office 2010
    Posts
    6

    Re: index match - 2 criteria, one approximate

    Working well thank you both for the help!

  12. #12
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: index match - 2 criteria, one approximate

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. Index(Match) with 2 criteria, one of which is approximate
    By mikeronni in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-12-2014, 01:38 PM
  2. [SOLVED] INDEX & MATCH for approximate matches or combine VLOOKUP & HLOOKUP
    By michaljireht in forum Excel General
    Replies: 4
    Last Post: 12-01-2014, 08:41 PM
  3. [SOLVED] Combining 3 Formulas: Return all Names that Match Criteria Using Index/Match
    By bchilme in forum Excel Formulas & Functions
    Replies: 20
    Last Post: 09-29-2014, 09:28 AM
  4. Replies: 2
    Last Post: 09-27-2014, 04:34 PM
  5. Replies: 6
    Last Post: 04-30-2014, 02:42 AM

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