+ Reply to Thread
Results 1 to 9 of 9

Return Max value of two columns IF date criteria is met

  1. #1
    Registered User
    Join Date
    01-04-2013
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    4

    Return Max value of two columns IF date criteria is met

    Hi guys,

    Im new here, but after spending many hours on this following issue I nearly lost my mind and therefore decided to ask you guys!

    In order to calculate so called pivot points for a certain stock i need to extract the max and min value of stock levels on certain dates. In the situation in the attachment I need a formula that, given a startdate (col D) and time interval (col E) , returns first date after time interval (col F) max (col G) and min values (col H)

    Col A: date
    Col B: prices
    Col C: prices
    Col D: start date
    Col E: Time interval in days
    Col F: first date after time interval
    Col G & H should be returned as min and max



    See attachment.

    Your help would be appreciated greatly
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    01-17-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    402

    Re: Return Max value of two columns IF date criteria is met

    Please see the reply which is attached and the formulas are highlighted in yellow color.
    Attached Files Attached Files

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Return Max value of two columns IF date criteria is met

    1) Put this array formula into G1 and confirm it by pressing CTRL-SHIFT-ENTER:

    =MAX(IF($A$3:$A$13=$F3, B3:B13+0, ""))

    You will see curly braces { } appear around your formula to indicate an array is active in that cell. If you do not, try again. Ctrl-Shift-Enter will activate the array.

    2) Now copy that down as needed. 6/29/2012 works because it's in the data range, 7/1/2013 does not.

    3) Put this array formula in H3

    =MIN(IF($A$3:$A$13=$F3, C3:C13+0, ""))



    4) When you expand those formulas later to encompass more data, don't try to use a whole column, that won't work.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    01-04-2013
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Return Max value of two columns IF date criteria is met

    Hi Jerry thanks for your help,

    If I try your formula it returns #VALUE, and if I remove the +0 the formula returns 0. What am I doing wrong? By the way, I need the max value of the two columns combined but that is easy by simply changing it into =MAX(IF($A$3:$A$13=$F3, B3:C13+0, "")). Also, you said that it will not work if I drag it down entirely accross a column, but this is exactly what I need. Any suggestions?

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Return Max value of two columns IF date criteria is met

    No, what he said was that it will not work if you USE an entire column (B:B), not if you drag it across columns

    if it's not working for you, are you sure you entered it by holding doun the CRTL and SHIFT keys together, and then pressed enter (while CTRL SHIFT are still pressed down)?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Return Max value of two columns IF date criteria is met

    I don't recommend using the whole column (it can be slow) but there's no reason it won't work in Excel 2007 or later versions, e.g. this works for me in Excel 2010

    =MAX(IF(A:A=$F3,B:C+0))

    confirmed with CTRL+SHIFT+ENTER
    Audere est facere

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Return Max value of two columns IF date criteria is met

    Quote Originally Posted by Medir View Post
    If I try your formula it returns #VALUE, and if I remove the +0 the formula returns 0. What am I doing wrong? By the way, I need the max value of the two columns combined but that is easy by simply changing it into =MAX(IF($A$3:$A$13=$F3, B3:C13+0, "")).
    When you enter the formula and press CTRL-SHIFT-ENTER, so the curly braces appear around the formula? If not, try again. You need the braces to appear, the array must be active, else you'll get a #VALUE error.

  8. #8
    Registered User
    Join Date
    01-04-2013
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Return Max value of two columns IF date criteria is met

    guys thank you very much,

    Issue is solved!

  9. #9
    Valued Forum Contributor
    Join Date
    07-27-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    826

    Re: Return Max value of two columns IF date criteria is met

    Medir,

    If your query has been answered to your satisfaction (as your post above suggests), could you please mark this thread as SOLVED - you can do this by using the Thread Tools, and clicking on "Mark thread as solved".

    Also, as a newcomer, you may not know that you can thank those who assisted you by clicking on the * icon at the bottom left of any post you found helpful.

    And last, but not least - welcome to the forum!
    Brendan.


    __________________________________________________________________________________________________
    Things to consider:

    1) You can thank any poster by clicking the * at the left of a helpful post.
    2) You can help to keep the forum tidy by marking your thread as "Solved", if it has been answered to your satisfaction.
    3) Help us to help you, by uploading a sample workbook, showing the type of data you're dealing with, and clearly indicating what the results should be.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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