Two way lookup with if/match return

sanrama

New Member
Joined
May 2, 2015
Messages
23
Office Version
  1. 2013
Platform
  1. Windows
Hi All,

Need help, I am struggling to find the solution. Below is my details,


ABCDEFGHIJ
1NameDate12345678
2DayFriSatSunMonTueWedThuFri
3Mr. ABBBAAOBA
4Mr. BAAOBBLOB
5Mr. CLOLLLBAA
6Mr. DGBOGGLGG
7Mr. EGGAOGLGG


Case 1
Lookup 12Date ( in raw 1 )
Lookup 2BColumn F ( Lookup 1 matching column, in this case it matching column array is G3:G7 )
Result 1Mr. A
Result 2Mr. D
Result 3
Result 4

Case 2
Lookup 16Date ( in raw 1 )
Lookup 2LColumn F ( Lookup 1 matching column, in this case it matching column array is K3:K7 )
Result 1Mr. B
Result 2Mr. D
Result 3Mr. E
Result 4



Thanks in advance
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Hi Sanrama,

I'm a little confused as a date of 2 and a lookup of B suggests I should look in column D where I'd only find Mr. A.

For case 2 I'd look in column H and find no entries for L.
 
Upvote 0
It is a very bad example, but I think that this is what is required.
Manpower plan.xlsx
ABCDEFGHIJ
1Name12345678
2DayFriSatSunMonTueWedThuFri
3Mr. ABBBAAOBA
4Mr. BAAOBBLOB
5Mr. CLOLLLBAA
6Mr. DGBOGGLGG
7Mr. EGGAOGLGG
8
9Case 1
10Lookup 12
11Lookup 2B
12
13Result 1Mr. A
14Result 2Mr. D
15Result 3
16Result 4
Sheet5
Cell Formulas
RangeFormula
B13:B14B13=FILTER(A3:A7,INDEX(B3:I7,0,MATCH(B10,B1:I1,0))=B11,"")
Dynamic array formulas.
 
Upvote 0
Hi Toadstool, Hi jasonb75,

Extremely sorry for incorrect data,
Please find below screenshot for corrected data

Untitled.png
 
Upvote 0
I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Have you tried the formula that Jason supplied in post#3?
 
Upvote 0
Hi Fluff / Jeson,

Currently I am using Excel 2013, so filter formula is not available in the version.
 
Upvote 0
Hi Sanrama,

Try this:

Sanrama.xlsx
ABCDEFGHI
1Name12345678
2DayFriSatSunMonTueWedThuFri
3Mr. ABBBAAOBA
4Mr. BAAOBBLOB
5Mr. CLOLLLBAA
6Mr. DGBOGGLGG
7Mr. EGGAOGLGG
8
9Case 1
10Lookup 12
11Lookup 2B
12
13Result 1Mr. A
14Result 2Mr. D
15Result 3 
16Result 4 
17
18Case 1
19Lookup 16
20Lookup 2L
21
22Result 1Mr. B
23Result 2Mr. D
24Result 3Mr. E
25Result 4 
Sheet1
Cell Formulas
RangeFormula
B13:B16B13=IFERROR(INDEX($A$3:$A$7,AGGREGATE(15,6,ROW($A$3:$A$7)-ROW($A$2)/(($B$1:$I$1=$B$10)*($B$3:$I$7=$B$11)),ROW()-ROW($B$12))),"")
B22:B25B22=IFERROR(INDEX($A$3:$A$7,AGGREGATE(15,6,ROW($A$3:$A$7)-ROW($A$2)/(($B$1:$I$1=$B$19)*($B$3:$I$7=$B$20)),ROW()-ROW($B$21))),"")
 
Upvote 0
Thanks for updating your profile, how about
+Fluff v2.xlsm
ABCDEFGHI
1Name12345678
2DayFriSatSunMonTueWedThuFri
3Mr. ABBBAAOBA
4Mr. BAAOBBLOB
5Mr. CLOLLLBAA
6Mr. DGBOGGLGG
7Mr. EGGAOGLGG
8
9Case 1
10Lookup 12
11Lookup 2B
12
13Result 1Mr. A
14Result 2Mr. D
15Result 3 
16Result 4 
17
Data
Cell Formulas
RangeFormula
B13:B16B13=IFERROR(INDEX($A$3:$A$7,AGGREGATE(15,6,(ROW($B$3:$I$7)-ROW($B$3)+1)/($B$1:$I$1=$B$10)/($B$3:$I$7=$B$11),ROWS(B$13:B13))),"")
 
Upvote 0
2 more methods that would be slightly more efficient. This is trivial with small data sets like your example, but with larger data sets it can be quite noticeable, especially on lower powered computers.
The formula in B13 is almost identical to the suggestions above, but by starting the index range in row 1 instead of row 3 it is possible to reduce the number of calculation steps in the aggregate array.

The formula in C13 takes it one step further by eliminating the date check from the array but this will only work if the dates in row 1 are always consecutive and starting from the 1st.

Book1 (version 1).xlsb
ABCDEFGHI
1Name12345678
2DayFriSatSunMonTueWedThuFri
3Mr. ABBBAAOBA
4Mr. BAAOBBLOB
5Mr. CLOLLLBAA
6Mr. DGBOGGLGG
7Mr. EGGAOGLGG
8
9Case 1
10Lookup 12
11Lookup 2B
12
13Result 1Mr. AMr. A
14Result 2Mr. DMr. D
15Result 3  
16Result 4  
Sheet8
Cell Formulas
RangeFormula
B13:B16B13=IFERROR(INDEX($A$1:$A$7,AGGREGATE(15,6,ROW($A$3:$A$7)/($B$3:$I$7=$B$11)/($B$1:$I$1=$B$10),ROWS(B$13:B13))),"")
C13:C16C13=IFERROR(INDEX($A$1:$A$7,AGGREGATE(15,6,ROW($A$3:$A$7)/(INDEX($B$3:$I$7,,$B$10)=$B$11),ROWS(C$13:C13))),"")
 
Upvote 0
Solution
The formula in B13 is almost identical to the suggestions above, but by starting the index range in row 1 instead of row 3 it is possible to reduce the number of calculation steps in the aggregate array.
Except that if rows are inserted above the first row of data, the formula will fail.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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