Index Match - Multiple Criteria with Great Than

Josh123

New Member
Joined
Dec 11, 2013
Messages
18
Hi,

In this scenario, I need a formula to return a specific value based on (1) a criteria with an exact match, and (2) a range criteria where there is not always an exact match.
  • Table 1 contains the criteria of the lookup (Year and Number), as well as the value I want the formula to return (Score).
  • Table 2 is the dataset containing the Score value along with the associated criteria.

Criteria 1
  • The first criteria for the lookup is based on the Year field.
  • The year in Table 1 needs to match the year in Table 2.

Criteria 2 and 3
  • The second and third criteria for the lookup is based on the Number field in Table 1 and the Minimum and Maximum fields in Table 2.
  • The Number value must be greater than or equal to the Minimum field values and must be less than or equal to the Maximum field values.

The values in the Minimum and Maximum fields may overlap, so the criteria must take into consideration both fields for a good match.

Table 1
YearNumberScore
201773

<tbody>
</tbody>




Table 2

Criteria 1
Year
Criteria 2
Minimum
Criteria 3
Maximum
Return Value
Score
20160101
20165152
20175153

<tbody>
</tbody>
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
@Josh, it's not clear what should be done with the overlapping ranges (which is very odd, by the way). For instance, if your Table-1 data had the Year 2016 and the Number 7, what would you expect the score to be — 1 or 2 — and how would you make that determination?
 
Upvote 0
@ErikTyler,

After reviewing your simulation, I have realized the criteria rules for the range need to be modified - thank you.

Revisions:

  • Disregard the Maximum field (criteria 3)
  • The Number in Table 1 must be greater than or equal to the value in the Minimum field (assuming the years match)

Please use this revised table for this same example:

Table 1 (revised)
YearNumberScore
201641

<tbody>
</tbody>
 
Upvote 0
@Josh123, OK, I've worked it out so that the score will be retrieved from the maximum range per year.

My formula assumes the following:

1. That your "Table 1" headers are in A1:C1.

2. That your "Table 2" headers are in E1:H1.

Given that setup, this formula would go in C2 (and then be drag-copied down if/as needed):

=IFERROR(INDIRECT("H"&SUMPRODUCT(MAX(($E$2:$E$4=A2)*($F$2:$F$4<=B2)*($G$2:$G$4>=B2)*(ROW($E$2:$E$4))))),"* NONE *")
 
Upvote 0
Josh123

Is it possible that no match could be found? For example, in post #1 what if Table 1 had 2017 and the number 3? I ask, because the minimum value shown in Table 2 for 2017 is 5.
 
Upvote 0
@Peter, I had the same question, so I just included an IFERROR( ,"* NONE *") wrapper.
Fair enough Erik, but I'm considering the possibility of a much simpler formula that also avoids the volatile function INDIRECT. I'm also trying to avoid the potential problem of having to edit the formulas that would arise with your formula if the user subsequently decides to insert, say, a new column A.

The answer to the question I've asked is relevant to what I have in mind.
 
Upvote 0
@Peter, I will look forward to seeing what you come up with. Always enjoy learning something new.

In the meantime, an adaptation of my formula without INDIRECT():

=IFERROR(INDEX($H$2:$H$4, SUMPRODUCT(MAX(($E$2:$E$4=A2)*($F$2:$F$4<=B2)*($G$2:$G$4>=B2)*(ROW($E$2:$E$4))))-1),"* NONE *")
 
Upvote 0
@Peter_SSs,

It will not be possible that no match will be found. The Minimum field will always contain a value that is equal to or less than the Number value in Table 1 for each year. The largest value in the Minimum field in the dataset will contain a value which could be less than or equal to the Number value (but the corresponding Maximum value in that same row will be an "infinite" value because it will be quite large). So in the event the Number value is larger than the largest value in the Minimum field, the formula should return the Score value in that largest Minimum value row.


@ ErikTyler,

I have applied your formula to my dataset, but it doesn't seem to be working. The formula return is always pulling the Score value associated with the smallest value in the Minimum field from the largest Year value.

I have revised Tables 1 and 2 for additional clarification:

A

Year
B

Number
C

Score
201601
20161005
2017189
201710010

<tbody>
</tbody>











Table 2 (Revised)
E

Year
F

Minimum
G

Maximum
H

Score
2016051
20165102
201610153
201615204
2016209995
2017056
20175107
201710158
201715209
20172099910

<tbody>
</tbody>
 
Upvote 0
Hey, Josh. I entered your data from the new tables above, and got all the same answers you have using the formula I provided. So something is fishy.
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,520
Members
448,968
Latest member
Ajax40

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top