条件 Vlookup 3 个搜索词一个 table
Conditional Vlookup 3 search terms one table
有没有一种方法可以在一个 table 上使用 3 个不同的搜索词进行 Vlookup?
例如,我想通过 SamAcctName 或 UserLogonName 或 TestName 在一个大数据池中查找
Search terms
SamAcctName | UserLogonName | TestName | result |
---------------|------------------------|-------------|------------------|
test.user | testuser@test.com | testus | Result 1 <<<<<< |
---------------|------------------------|-------------|------------------|
estuser | other@test.com | testuseer | Result 2 <<<<<< |
---------------|------------------------|-------------|------------------|
Table with all data records
Name | Description | moredata |
--------------|-------------------------|--------------------|
Test.User | Result 1 <<<<<<< | Blah Blah BLah |
--------------|-------------------------|--------------------|
other@test.com| user ..Blah Blah | Blah Blah BLah |
--------------|-------------------------|--------------------|
other.user | user ..Blah Blah | Blah Blah BLah |
--------------|-------------------------|--------------------|
TestUser2 | user ..Blah Blah | Blah Blah BLah |
--------------|-------------------------|--------------------|
other.user | user ..Blah Blah | Blah Blah BLah |
--------------|-------------------------|--------------------|
other@test.com| Result 2 <<<<<<< | Blah Blah BLah |
--------------|-------------------------|--------------------|
other.user | user ..Blah Blah | Blah Blah BLah |
--------------|-------------------------|--------------------|
一个简单的大锤方法是编写嵌套 IFERROR(VLOOKUP...
如下公式。
=IFERROR(VLOOKUP(A2,F:G,2,0),IFERROR(VLOOKUP(B2,F:G,2,0),IFERROR(VLOOKUP(C2,F:G,2,0),"")))
其中 F&G 列包含所有数据 table,第一个 table 在 A2:D3
范围内。
=INDEX(D1:D3,MATCH(1,MMULT(--(A1:C3=E1),TRANSPOSE(COLUMN(A1:C3)^0)),0))
这是数组函数,要用ctrl + shift + enter
输入
一个数组是从 A1:C3=E1
创建为 1 或 2(TRUE 或 FALSE)。该数组是 3 列和范围的长度。
第二个数组是用 TRANSPOSE(COLUMN(A1:C3)^0)
创建的,结果是 {1, 2, 3}
,0 次方是 {1, 1, 1}
。
MMULT 将这些数组相乘,结果是匹配值的行号。
INDEX 在该行的索引列中显示结果值。
编辑:我刚刚意识到我使用 E1 作为查找值,但在您的情况下将其更改为适用于您的单元格。此外,数据范围是一个假设,可能需要修改。
反映您的数据如下:
搜索词从 H2 到 I500,数据池从 A2 到 F1465,我假设要显示的结果数据来自 B 列:
=INDEX(B2:B1465,MATCH(1,MMULT(--(H2:I500=A1),TRANSPOSE(COLUMN(H2:I500)^0)),0))
有没有一种方法可以在一个 table 上使用 3 个不同的搜索词进行 Vlookup? 例如,我想通过 SamAcctName 或 UserLogonName 或 TestName 在一个大数据池中查找
Search terms
SamAcctName | UserLogonName | TestName | result |
---------------|------------------------|-------------|------------------|
test.user | testuser@test.com | testus | Result 1 <<<<<< |
---------------|------------------------|-------------|------------------|
estuser | other@test.com | testuseer | Result 2 <<<<<< |
---------------|------------------------|-------------|------------------|
Table with all data records
Name | Description | moredata |
--------------|-------------------------|--------------------|
Test.User | Result 1 <<<<<<< | Blah Blah BLah |
--------------|-------------------------|--------------------|
other@test.com| user ..Blah Blah | Blah Blah BLah |
--------------|-------------------------|--------------------|
other.user | user ..Blah Blah | Blah Blah BLah |
--------------|-------------------------|--------------------|
TestUser2 | user ..Blah Blah | Blah Blah BLah |
--------------|-------------------------|--------------------|
other.user | user ..Blah Blah | Blah Blah BLah |
--------------|-------------------------|--------------------|
other@test.com| Result 2 <<<<<<< | Blah Blah BLah |
--------------|-------------------------|--------------------|
other.user | user ..Blah Blah | Blah Blah BLah |
--------------|-------------------------|--------------------|
一个简单的大锤方法是编写嵌套 IFERROR(VLOOKUP...
如下公式。
=IFERROR(VLOOKUP(A2,F:G,2,0),IFERROR(VLOOKUP(B2,F:G,2,0),IFERROR(VLOOKUP(C2,F:G,2,0),"")))
其中 F&G 列包含所有数据 table,第一个 table 在 A2:D3
范围内。
=INDEX(D1:D3,MATCH(1,MMULT(--(A1:C3=E1),TRANSPOSE(COLUMN(A1:C3)^0)),0))
这是数组函数,要用ctrl + shift + enter
一个数组是从 A1:C3=E1
创建为 1 或 2(TRUE 或 FALSE)。该数组是 3 列和范围的长度。
第二个数组是用 TRANSPOSE(COLUMN(A1:C3)^0)
创建的,结果是 {1, 2, 3}
,0 次方是 {1, 1, 1}
。
MMULT 将这些数组相乘,结果是匹配值的行号。
INDEX 在该行的索引列中显示结果值。
编辑:我刚刚意识到我使用 E1 作为查找值,但在您的情况下将其更改为适用于您的单元格。此外,数据范围是一个假设,可能需要修改。
反映您的数据如下:
搜索词从 H2 到 I500,数据池从 A2 到 F1465,我假设要显示的结果数据来自 B 列:
=INDEX(B2:B1465,MATCH(1,MMULT(--(H2:I500=A1),TRANSPOSE(COLUMN(H2:I500)^0)),0))