+ Reply to Thread
Results 1 to 8 of 8

Conditional maximum and minimum values

  1. #1
    Registered User
    Join Date
    01-20-2013
    Location
    Massachusetts, USA
    MS-Off Ver
    Excel 2003
    Posts
    48

    Conditional maximum and minimum values

    I have an array of "x" and "y" data which gets updated frequently.

    I need to calculate the maximum value of "x" that has a "y" value < a value give in a specific reference cell outside the array.

    I also need to calculate the minimum value of "x" that has a "y" value >= that same reference value.

    To make it a little less abstract, here is a hypothetical example. I have set of data with x=height and y=weight. I have a reference cell into which I type a weight; say 175 pounds in this example. So I need to write formulas that find, in the x-y array, the tallest person less than 175 pounds and the shortest person >=175 pounds.

    So another way to look at it might be to say, "Find the maximum value of "x" looking only at data pairs that have "y" < 175, find the minimum value of "x" looking only at data pairs that have "y" >= 175

    Often when I am really stuck with tough formula coding, I will write some intermediate cells with formulae that get me to an answer when I can't figure out how to do it in one cell (by this I mean one cell for each condition). That type of solution would be acceptable here.

    Thanks for any help and/or suggestions,
    metsci
    Last edited by metsci; 01-20-2013 at 11:31 PM. Reason: mark as solved

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,592

    Re: Conditional maximum and minimum values

    What if there are more same values?

    Can you please upload example workbook with your input and desired output (including above question).

  3. #3
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Conditional maximum and minimum values

    See if you can adapt these array formula

    Cell F1 is used as the "weight" inlut cell

    {=MAX(IF(B2:B100<F1,A2:A100))}

    {=MIN(IF(B2:B100>=F1,A2:A100))}

    Array formulas are committed using key combination Ctrl + Shift + Enter.
    Adjust range references as needed.
    Last edited by Palmetto; 01-20-2013 at 12:26 PM.
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  4. #4
    Registered User
    Join Date
    01-20-2013
    Location
    Massachusetts, USA
    MS-Off Ver
    Excel 2003
    Posts
    48

    Re: Conditional maximum and minimum values

    Palmetto,

    Mega-thanks. This is a simple, efficient solution.

    I haven't really paid sufficient attention to array formulas AND I was unaware that you could put a logical inside a function.

    Thus, this solution of yours will help me in many other places.

    I worked out a nice example workbook that implements your solution for a hypothetical case, but I'm a "newbie" in this forum and haven't yet figured out how to attach a file to this post.

    If you want to give me one more bit of help on how to do that, I'll upload the file.

    metsci

  5. #5
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Conditional maximum and minimum values

    Click Edit Post below your post, then click Go Advanced and scroll down to Manage Attachments.

  6. #6
    Registered User
    Join Date
    01-20-2013
    Location
    Massachusetts, USA
    MS-Off Ver
    Excel 2003
    Posts
    48

    Re: Conditional maximum and minimum values

    Palmetto,

    Here is an attachment with a sample file implementing your solution.

    I already gave you a Star rating.

    metsci
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    01-20-2013
    Location
    Massachusetts, USA
    MS-Off Ver
    Excel 2003
    Posts
    48

    Re: Conditional maximum and minimum values

    Done.

    Can you now teach me how to mark a post as "solved".

    Also, should I mark the original qestion post as solved?

    metsci

  8. #8
    Registered User
    Join Date
    01-20-2013
    Location
    Massachusetts, USA
    MS-Off Ver
    Excel 2003
    Posts
    48

    Re: Conditional maximum and minimum values

    Done!

    It's marked as solved.

    Thanks again.

+ 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