Index Match Return values if multiple array conditions are met

cyrilbrd

Well-known Member
Joined
Feb 2, 2012
Messages
4,113
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Given in A1:
<style>table { }td { padding-top: 1px; padding-right: 1px; padding-left: 1px; color: black; font-size: 12pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: Calibri,sans-serif; vertical-align: bottom; border: medium none; white-space: nowrap; }.xl63 { text-align: center; }</style> [TABLE="width: 325"]
<colgroup><col style="width:65pt" span="5" width="65"> </colgroup><tbody>[TR]
[TD="class: xl63, width: 65"]identifier[/TD]
[TD="class: xl63, width: 65"]R1
[/TD]
[TD="class: xl63, width: 65"]R2[/TD]
[TD="class: xl63, width: 65"]R3[/TD]
[TD="class: xl63, width: 65"]R4[/TD]
[/TR]
[TR]
[TD="class: xl63"]yes[/TD]
[TD="class: xl63"]16
[/TD]
[TD="class: xl63"]15[/TD]
[TD="class: xl63"]54[/TD]
[TD="class: xl63"]53[/TD]
[/TR]
[TR]
[TD="class: xl63"][/TD]
[TD="class: xl63"]23[/TD]
[TD="class: xl63"]15[/TD]
[TD="class: xl63"]12[/TD]
[TD="class: xl63"]55[/TD]
[/TR]
[TR]
[TD="class: xl63"]yes[/TD]
[TD="class: xl63"]34
[/TD]
[TD="class: xl63"]14[/TD]
[TD="class: xl63"]54[/TD]
[TD="class: xl63"]50[/TD]
[/TR]
[TR]
[TD="class: xl63"][/TD]
[TD="class: xl63"]55[/TD]
[TD="class: xl63"]56[/TD]
[TD="class: xl63"]100[/TD]
[TD="class: xl63"]89[/TD]
[/TR]
[TR]
[TD="class: xl63"]yes[/TD]
[TD="class: xl63"]80
[/TD]
[TD="class: xl63"]31[/TD]
[TD="class: xl63"]32[/TD]
[TD="class: xl63"]24[/TD]
[/TR]
[TR]
[TD="class: xl63"][/TD]
[TD="class: xl63"]45[/TD]
[TD="class: xl63"]78[/TD]
[TD="class: xl63"]83[/TD]
[TD="class: xl63"]93[/TD]
[/TR]
</tbody>[/TABLE]

formula in A2 is =IF(AND(B2>C2,D2>E2),"yes","") hence conditions for the row are R1 superior to R2 AND R3 superior to R4.

Result Expected in G1:
<style>table { }td { padding-top: 1px; padding-right: 1px; padding-left: 1px; color: black; font-size: 12pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: Calibri,sans-serif; vertical-align: bottom; border: medium none; white-space: nowrap; }.xl63 { text-align: center; }</style> [TABLE="width: 390"]
<colgroup><col style="width:65pt" span="6" width="65"> </colgroup><tbody>[TR]
[TD="width: 65"][/TD]
[TD="class: xl63, width: 65"][/TD]
[TD="class: xl63, width: 65"]R1_r
[/TD]
[TD="class: xl63, width: 65"]R2_r
[/TD]
[TD="class: xl63, width: 65"]R3_r
[/TD]
[TD="class: xl63, width: 65"]R4_r
[/TD]
[/TR]
[TR]
[TD]result[/TD]
[TD="class: xl63"]yes[/TD]
[TD="class: xl63"]16[/TD]
[TD="class: xl63"]15[/TD]
[TD="class: xl63"]54[/TD]
[TD="class: xl63"]53[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl63"]yes[/TD]
[TD="class: xl63"]34[/TD]
[TD="class: xl63"]14[/TD]
[TD="class: xl63"]54[/TD]
[TD="class: xl63"]50[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl63"]yes[/TD]
[TD="class: xl63"]80[/TD]
[TD="class: xl63"]31[/TD]
[TD="class: xl63"]32[/TD]
[TD="class: xl63"]24[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl63"][/TD]
[TD="class: xl63"][/TD]
[TD="class: xl63"][/TD]
[TD="class: xl63"][/TD]
[TD="class: xl63"][/TD]
[/TR]
</tbody>[/TABLE]
formula presently used in H2 is =IF(ROWS($H$2:H2)>SUMPRODUCT(--(B:B>C:C),--(D:D>E:E)),"","yes") CSE copied down till needed
formula presently used in I2 is =IF(ROWS(I$2:I2)>SUMPRODUCT(--($B:$B>$C:$C),--($D:$D>$E:$E)),"",INDEX(B:B,SMALL(IF($A$2:$A$7=$H2,ROW($A$2:$A$7)),ROWS(I$2:I2)))) CSE copied right till Column L and down till needed.

NOTE:
The above scenario in A1 involves the use of a helper column in A returning either a 'yes' or a blank
The above results in G1 make use of Column A in order to retrieve all INDEX whenever the condition is met

QUESTION:
Could it be possible to invoke the two conditions within the search formula thus removing the need of Column A while returning all values fitting the conditions:
<style>table { }td { padding-top: 1px; padding-right: 1px; padding-left: 1px; color: black; font-size: 12pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: Calibri,sans-serif; vertical-align: bottom; border: medium none; white-space: nowrap; }.xl63 { text-align: center; }</style> [TABLE="width: 390"]
<colgroup><col style="width:65pt" span="6" width="65"> </colgroup><tbody>[TR]
[TD="width: 65"]count[/TD]
[TD="class: xl63, width: 65"]3[/TD]
[TD="class: xl63, width: 65"]R1[/TD]
[TD="class: xl63, width: 65"]R2[/TD]
[TD="class: xl63, width: 65"]R3[/TD]
[TD="class: xl63, width: 65"]R4[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl63"]Result
[/TD]
[TD="class: xl63"]16[/TD]
[TD="class: xl63"]15[/TD]
[TD="class: xl63"]54[/TD]
[TD="class: xl63"]53[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl63"][/TD]
[TD="class: xl63"]34[/TD]
[TD="class: xl63"]14[/TD]
[TD="class: xl63"]54[/TD]
[TD="class: xl63"]50[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl63"][/TD]
[TD="class: xl63"]80[/TD]
[TD="class: xl63"]31[/TD]
[TD="class: xl63"]32[/TD]
[TD="class: xl63"]24[/TD]
[/TR]
</tbody>[/TABLE]

Count would be =SUMPRODUCT(--(B:B>C:C),--(D:D>E:E)) CSE
but what would be the formula in I2?
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
An efficient set up would be:

[TABLE="width: 508"]
<TBODY>[TR]
[TD="class: xl63, width: 38, bgcolor: white"][/TD]
[TD="class: xl64, width: 64, bgcolor: white"]R1
[/TD]
[TD="class: xl64, width: 64, bgcolor: white"]R2
[/TD]
[TD="class: xl64, width: 64, bgcolor: white"]R3
[/TD]
[TD="class: xl64, width: 64, bgcolor: white"]R4
[/TD]
[TD="class: xl66, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 64, bgcolor: white"]Idx
[/TD]
[TD="class: xl64, width: 64, bgcolor: white"]R1
[/TD]
[TD="class: xl64, width: 64, bgcolor: white"]R2
[/TD]
[TD="class: xl64, width: 64, bgcolor: white"]R3
[/TD]
[TD="class: xl64, width: 64, bgcolor: white"]R4
[/TD]
[/TR]
[TR]
[TD="class: xl63, width: 38, bgcolor: white"][/TD]
[TD="class: xl65, width: 64, bgcolor: white"]16
[/TD]
[TD="class: xl65, width: 64, bgcolor: white"]15
[/TD]
[TD="class: xl65, width: 64, bgcolor: white"]54
[/TD]
[TD="class: xl65, width: 64, bgcolor: white"]53
[/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]1
[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]16
[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]15
[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]54
[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]53
[/TD]
[/TR]
[TR]
[TD="class: xl63, width: 38, bgcolor: white"][/TD]
[TD="class: xl63, width: 64, bgcolor: white"]23
[/TD]
[TD="class: xl63, width: 64, bgcolor: white"]15
[/TD]
[TD="class: xl63, width: 64, bgcolor: white"]12
[/TD]
[TD="class: xl63, width: 64, bgcolor: white"]55
[/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]3
[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]34
[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]14
[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]54
[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]50
[/TD]
[/TR]
[TR]
[TD="class: xl63, width: 38, bgcolor: white"][/TD]
[TD="class: xl65, width: 64, bgcolor: white"]34
[/TD]
[TD="class: xl65, width: 64, bgcolor: white"]14
[/TD]
[TD="class: xl65, width: 64, bgcolor: white"]54
[/TD]
[TD="class: xl65, width: 64, bgcolor: white"]50
[/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]5
[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]80
[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]31
[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]32
[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]24
[/TD]
[/TR]
[TR]
[TD="class: xl63, width: 38, bgcolor: white"][/TD]
[TD="class: xl63, width: 64, bgcolor: white"]55
[/TD]
[TD="class: xl63, width: 64, bgcolor: white"]56
[/TD]
[TD="class: xl63, width: 64, bgcolor: white"]100
[/TD]
[TD="class: xl63, width: 64, bgcolor: white"]89
[/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl63, width: 38, bgcolor: white"][/TD]
[TD="class: xl65, width: 64, bgcolor: white"]80
[/TD]
[TD="class: xl65, width: 64, bgcolor: white"]31
[/TD]
[TD="class: xl65, width: 64, bgcolor: white"]32
[/TD]
[TD="class: xl65, width: 64, bgcolor: white"]24
[/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl63, width: 38, bgcolor: white"][/TD]
[TD="class: xl63, width: 64, bgcolor: white"]45
[/TD]
[TD="class: xl63, width: 64, bgcolor: white"]78
[/TD]
[TD="class: xl63, width: 64, bgcolor: white"]83
[/TD]
[TD="class: xl63, width: 64, bgcolor: white"]93
[/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[/TR]
</TBODY>[/TABLE]

Data is located in B1:E7, with headers in B1:E1; the processing in G:K.

G2, control+shift+enter, not just enter, and copy down:
Rich (BB code):
=IFERROR(SMALL(IF(($B$2:$B$7>$C$2:$C$7)*($D$2:$D$7>$E$2:$E$7),
  ROW($B$2:$B$7)-ROW($B$2)+1),ROWS($G$2:G2)),"")

H2, just enter, copy across, and down:
Rich (BB code):
=IF($G2="","",INDEX(B$2:B$7,$G2))
 
Upvote 0
Rich (BB code):
=IFERROR(SMALL(IF(($B$2:$B$7>$C$2:$C$7)*($D$2:$D$7>$E$2:$E$7),
  ROW($B$2:$B$7)-ROW($B$2)+1),ROWS($G$2:G2)),"")

Rich (BB code):
=IF($G2="","",INDEX(B$2:B$7,$G2))

Would it be a problem If we used the whole Column Range? would it possibly trigger conflict within Excel or would it be acceptable such as in Sheet2:
Rich (BB code):
=IFERROR(SMALL(IF((Sheet1!B:B>Sheet1!C:C)*(Sheet1!D:D>Sheet1!E:E),
  ROW(Sheet1!B:B)-ROW($A$2)+1),ROWS(A$2:$A2)),"")
and
Rich (BB code):
=IF($A2="","",INDEX(Sheet1!B:B,$A2+1))

Your solution is very elegant.
The addition of conditions would be to be taken care here right?

Rich (BB code):
=IFERROR(SMALL(IF((range1 condition_1 range2)*(range3 condition_2 range4)*(rangex condition_n rangey),   ROW(range)-ROW($B$2)+1),ROWS($G$2:G2)),"")
</pre>
 
Upvote 0
Yes. It would adversely affect the efficiency. A better alternative is to use dynamic named ranges.

Aladin, Thank you for the fast and concise reply.
it is exactly what I was looking for. I should have thought of the row as a medium to get to correct answer...

Thanks again, it is perfect.
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,987
Members
452,373
Latest member
TimReeks

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