简体   繁体   中英

Problems with implementing a two criteria vlookup substitute (sumproduct or index)

I have data on two tables, DATA and SpreadCodes. I need to write a formula that functions like a two-criteria vlookup. My tables look like this:

DATA table:

Col B  ...  Col I 
01142        589       
57834        007 

Where Column S is where I'm trying to put the formula and where entries in Columns B & I are numbers stored as text.

SpreadCodes table:

Col A  ...  Col E ... Col G ... Col J
57834       007       15.50     15.50
45785       35893     10.00     10.00

Where entries in Columns A,E & G are numbers stored as text and where entries in Column J are stored as numbers.

I am trying to search the SpreadCodes table for the row where entries in DATA column B equal SpreadCodes Column A and where Data Column I equal SpreadCodes column E. Once a match is found, I need it to return the value in SpreadCodes column G OR Column J (They are the same, except G is stored as text, J is stored as number, so whichever makes this work).

I have tried several approaches to try to make this work. Nothing I tried below would return anything except an #NA value

I first tried creating a "helper" column where I concatenated the columns in both tables then just compared those values.

I then tried using two different index/match formulas (where one has concatenation included) :

=INDEX(SpreadCodes!G2:G202,MATCH(1,(SpreadCodes!A2:A202=B2)*(SpreadCodes!E2:E202=I2),0),7)

=INDEX(SpreadCodes!A1:K202,MATCH(Sheet2!B2&Sheet2!I2,SpreadCodes!A:A&SpreadCodes!E:E,0),7)

When that didn't work, I tried a sumproduct formula (being careful to specify SpreadCodes column J, since that one was a numerical value):

=SUMPRODUCT((SpreadCodes!A2:A202=Sheet2!C2)*(SpreadCodes!E2:E202=Sheet2!I2)*(SpreadCodes!J2:J202))

Since these codes often have leading zeros, I keep the columns in text so they don't get cut off, but even still, I'm not sure why these formulas aren't working. I've seen these work for other data. Any thoughts/ideas would be appreciated.

The sumproduct() works for me.

=SUMPRODUCT((SpreadCodes!A1:A100=Data!B1)*(SpreadCodes!E1:E100=Data!I1)*(SpreadCodes!J1:J100))

As per your data, This is how my data sheet looks like

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM