+ Reply to Thread
Results 1 to 10 of 10

using INDEX and IF to output value meeting multiple min/max range constraints

  1. #1
    Registered User
    Join Date
    04-30-2013
    Location
    USA
    MS-Off Ver
    Excel Mac 2011
    Posts
    6

    using INDEX and IF to output value meeting multiple min/max range constraints

    Hello Excel Forum!

    I am attempting to output a value based on 4 different min/max range constraints. I have tried using INDEX with a nested IF but have been unable to determine a solution. Please see attached spreadsheet for a more detailed description on the problem.

    Thanks,
    Andrew
    Attached Files Attached Files
    Last edited by myersac; 04-30-2013 at 04:14 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: using INDEX and IF to output value meeting multiple min/max range constraints

    Instead of looking up the values from the models sheet, why not just calculate the slope and index based on the input values on the main sheet ?
    Elegant Simplicity............. Not Always

  3. #3
    Registered User
    Join Date
    04-30-2013
    Location
    USA
    MS-Off Ver
    Excel Mac 2011
    Posts
    6

    Re: using INDEX and IF to output value meeting multiple min/max range constraints

    The slope and intercept are calculated from a separate, larger data set - so I am unable to do that.

  4. #4
    Valued Forum Contributor Lemice's Avatar
    Join Date
    04-13-2013
    Location
    Somewhere.
    MS-Off Ver
    Excel 2016
    Posts
    696

    Re: using INDEX and IF to output value meeting multiple min/max range constraints

    Hello,

    Welcome to the forum. You can use this Array formula
    Please Login or Register  to view this content.
    Confirm with Ctrl-Shift-Enter. If the formula is wrapped inside a { } then you did it right.

    I'm sorry it's not elegant, but it does the job.

    Here is your sample with formula.
    Attached Files Attached Files
    (copy pasta from Ford)
    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

    Regards,
    Lem

  5. #5
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,411

    Re: using INDEX and IF to output value meeting multiple min/max range constraints

    If there is only one unique combination in your tables that meet the criteria, then you could use this in E2 for the slope:

    =SUMPRODUCT((A2>=models!E2:E401)*(A2<=models!F2:F401)*(B2>=models!G2:G401)*(B2<=models!H2:H401)*(C2>=models!I2:I401)*(C2<=models!J2:J401)*(D2>=models!K2:K401)*(D2<=models!L2:L401),models!M2:M401)

    and this in F2 for the intercept:

    =SUMPRODUCT((A2>=models!E2:E401)*(A2<=models!F2:F401)*(B2>=models!G2:G401)*(B2<=models!H2:H401)*(C2>=models!I2:I401)*(C2<=models!J2:J401)*(D2>=models!K2:K401)*(D2<=models!L2:L401),models!N2:N401)

    Hope this helps.

    Pete

  6. #6
    Valued Forum Contributor Harribone's Avatar
    Join Date
    02-24-2013
    Location
    Midlands, UK
    MS-Off Ver
    Excel 2019/365
    Posts
    570

    Re: using INDEX and IF to output value meeting multiple min/max range constraints

    Another way would be to have 5 columns on the models sheet the first 4 check if the values entered are within the range. Each one that is returns 1. The fifth column checks if the sum of these is 4 (i.e. all criteria are met) and then returns 1.
    Back on the index sheet the slope/intercept values are found looking at the previously mentioned fifth column. Note if there a several matches then the first match is shown.
    Attached Files Attached Files
    Say thanks, click *

  7. #7
    Registered User
    Join Date
    04-30-2013
    Location
    USA
    MS-Off Ver
    Excel Mac 2011
    Posts
    6

    Re: using INDEX and IF to output value meeting multiple min/max range constraints

    Hey Lem, thank you for the help. This is very similar to what I was trying only I left out the SMALL and ROW() - 1 parts. Do you think you could share some explanation for how those fit in?

    Thanks,
    Andrew

  8. #8
    Valued Forum Contributor Lemice's Avatar
    Join Date
    04-13-2013
    Location
    Somewhere.
    MS-Off Ver
    Excel 2016
    Posts
    696

    Re: using INDEX and IF to output value meeting multiple min/max range constraints

    Because they are Array, I make the IF formula doing all the condition finding rows by rows, and it will return a list of rows which fit them ( ROW()'s job ). Then, SMALL( that list, 1 ) will find the smallest row among those list (First row fitting all condition)

    However, because you have a header row, I have to minus one (it's actually minus the row of where the Reference starts - row 2, and plus 1, but I'm lazy to to type it so I calculated myself and put -1 in there. The full part should have been ROW($A$2:$A$401)-ROW($A$2)+1 ). For example, the Index starts searching from row 2 to row 401 right? So for Index, first result is column 2, second result is column 3, etc ... That's why the -1.

  9. #9
    Registered User
    Join Date
    04-30-2013
    Location
    USA
    MS-Off Ver
    Excel Mac 2011
    Posts
    6

    Re: using INDEX and IF to output value meeting multiple min/max range constraints

    Pete and Harribone,

    Thank you so much, it is very helpful to see multiple solutions to the same problem!

    -Andrew

  10. #10
    Registered User
    Join Date
    04-30-2013
    Location
    USA
    MS-Off Ver
    Excel Mac 2011
    Posts
    6

    Re: using INDEX and IF to output value meeting multiple min/max range constraints

    Thanks Lem, very helpful explanation.

    I've been a forum member for about 2 hours now and am amazed by the speedy and helpful responses. Will definitely do my part to help solve problems in my own comfort zone.

    -Andrew

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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