I have an Excel spreadsheet with 3 columns. I would like to lookup for a value that can be in the first 2 and then get the corresponding value from the third one.
A B C
Mustang Empty Ford
Camaro Corvette Chevrolet
The VLOOKUP can only search in the first column. What I need is to be able to find a value in column A and B and return the value from C.
=VLOOKUP("Corvette",A1:C2,3,0) returns #N/A (would like to return Chevrolet)
=VLOOKUP("Camaro",A1:C2,3,0) returns Chevrolet
Is it possible?
use AGGREGATE:
=INDEX(C:C,AGGREGATE(15,7,ROW($A$1:$C$2)/($A$1:$C$2=E1),1))
If it is only three columns then this will be quicker:
=INDEX(C:C,IFERROR(IFERROR(MATCH(E1,A:A,0),MATCH(E1,B:B,0)),MATCH(E1,C:C,0)))
But as you can see adding an IFERROR for each column can get out of hand with more columns
Both the above will return the first encountered of the lookup. If the data set is unique, no duplicates in any of the columns the we can use the following.
this uses FILTER which is currently available on Office 365 for Insiders:
=FILTER(C:C,(A:A=E1)+(B:B=E1)+(C:C=E1))
But it does require that the data set be totally filled with unique. If one want to return all that match we can use TEXTJOIN to create a comma separated list:
=TEXTJOIN(",",TRUE,UNIQUE(FILTER(C:C,(A:A=E1)+(B:B=E1)+(C:C=E1))))
You can also try this:
=IFERROR(VLOOKUP(F2,$A$2:$C$3,3,0),VLOOKUP(F2,$B$2:$C$3,2,0))
where F2 is the look up item, and $A$2:$C$3 is the range of your 3 columns.
The logic is to use two VLOOKUP to return the value from the 3rd column if the look up value is in Column A, or return the value from the 2nd column if the look up value is in Column B.
Cheers :)
I like index-match a bit more for this:
=if(Isnumber(match(Thing, FirstColumn,0)),Index(ThirdColumn, Match(Thing, FirstColumn,0)),Index(ThirdColumn,Match(Thing, SecondColumn,0)))
Basically, test for existence in the first column. If its there, keep going, otherwise, use the second column.
Related
I have a list of names in column A on two separate sheets. Then, in columns B, C, and D - I have a Y or N. I'm trying to check the difference between sheet 1 and sheet 2.
Formula Function:
Check for value in Sheet1!A1 in Sheet2!A:A
If Sheet1!A1 matches (for example) Sheet2!A4,
Then check Sheet1B1:D1 against Sheet2!B4:D4
Return Match or No Match.
If Sheet1!A1 doesn't match any value in Sheet2!A:A, Return N/A
I've tried a couple dozen different combinations of VLookups, INDEX MATCH with an IF and AND to get it to confirm all three values, but can't seem to figure out how to combine all 3.
The COUNTIFS function is what you're looking for. Based on your description, something like this should work for you:
=IF(COUNTIF(Sheet2!A:A,Sheet1!A1)=0,"N/A",IF(COUNTIFS(Sheet2!A:A,Sheet1!A1,Sheet2!B:B,Sheet1!B1,Sheet2!C:C,Sheet1!C1,Sheet2!D:D,Sheet1!D1)=0,"No Match","Match"))
)
Try this (at home I have only the Dutch version, but tried my best to translate it to English formulas):
=IF(ISNA(VLOOKUP($A1;Sheet2!$A:$D;1;0));"N/A";IF(AND(VLOOKUP($A1;Sheet2!$A:$D;1;0)=$A1;VLOOKUP($A1;Sheet2!$A:$D;2;0)=$B1;VLOOKUP($A1;Sheet2!$A:$D;3;0)=$C1;VLOOKUP($A1;Sheet2!$A:$D;4;0)=$D1);"Match";"No Match"))
NOTE: This means the data in rows B:D on Sheet1 are in the exact same order as on Sheet2. If not, it will result in a "No Match".
Forgive me if this has been request before, any assistance is greatly appreciate.
I have the data below consisting of thousands of rows. I need to isolate rows only where the field1 and field2 columns match. is there a quick method of performing this in excel?
FileID1 FileID2 Hash
27468 27462 8BEA348CA9301F6459F8E8A2DD126D7C
29874 29843 EEFFBC24EAE3F4FD5ED5232993081A36
31150 1126 AE3675DC487DEF0F9C9FEC42B81B1438
**32330 32330 59D77968DB2FE6AFE42EEC21268F3D5A **
33218 33211 9231697E3A859F0D2C4E39AFB1C4AFFE
33984 33980 3B20A501EB17BA2A6FA6A43D9A3D70BA
35275 35260 201D7B2CE5E1DB924CAEDC0F7DA93489
**35402 35402 726C1DEE00F5D17EAB39B3DD1AE4EC0E **
35887 35883 176C07CD85BDD52449073310B9177977
36734 36657 2CDECE0B8C581D9E0F68B8BC3CEDAAB9
36924 36912 94BF549976E42D891F59A66C9972992E
BTW - I know that something like =IF(A1=B1,C1,"") but wanted something more refined where one does not have to copy the data, paste as text and then sort.
You can use if A column for first ID and B column is second ID and C column is the hash values you can use in D column as an expression like that
=IF(A1=B1,1,0)
this gives a value 1 for equal values and gives 0 for the non-equal values
or like your example
=IF(A1=B1,"**","")
To return the hashes where ID1 is equal to ID2, you can use this array formula:
=INDEX($C$2:$C$12,SMALL(IF($A$2:$A$12=$B$2:$B$12,ROW($C$2:$C$12)-ROW($C$2)+1),ROWS($C$2:C2)))
(enter with CTRL+SHIFT+ENTER).
You can wrap =IFERROR([formula above],"") to hide the #NUM! errors).
You can make some tweaks to that, if you're not after just the hashes. For instance, in D column, starting D2, you can use that same formula, just change the Index() columns at the start to be column A, and it'll return the IDs in column A that are duplicate too.
I have have two data sets which I need to compare. There is a column that is the common identifier between the two, but the 2nd data set, which is updated, has more than the 1st data set.
Here is how I extracted the data sets that I need:
What I'm trying to do is use columns D/I as the key, then see if columns C/H match. If they do not match I want that data returned or just highlighted.
I'm not very familiar with Excel, but I see the issue, in addition to what I described above, as being since the 2nd data set has more rows, the it will return those as highlighted, which it doesn't need to.
Any help would be great!
If I understood your problem correctly, you may try
=C2=INDEX(H:H,MATCH(D2,I:I,0))
and extend / drag this formula to check for more values in D column.
This formula results like this:
This formula compares values in D with values in I column and then compares corresponding C and H values and returns True when they match otherwise returns False.
In other words: This formula checks if a pair of Cx-Dx exactly matches with pair Hy-Iy where x and y are not necessarily equal.
E.g. (refer above screenshot)
C2-D2 matches with H2-I2
C3-D3 matches with H4-I4
C4-D4 matches with H3-I3
and C5-D5 matches with no pair in H:I range.
You can also use COUNTIFS either in a separate column or conditional formatting:-
=COUNTIFS($I:$I,$D2,$H:$H,"<>"&$C2)
to highlight the first two columns and
=COUNTIFS($D:$D,$I2,$C:$C,"<>"&$H2)
to highlight the second two columns.
I have a pivot table with format as follows:
I find the highest export quantity in all countries by the formula max(B2:D4) which comes out as 83.
Now I want to find the company name corresponding to this max value i.e. CompanyA in this case.
The actual pivot table has 241 rows and over 40 columns. But the layout is as described.
On Approach would be following formula:
=INDEX($A$1:$A$4,MAX(IF(B2:D4=MAX(B2:D4),ROW(B2:D4)-ROW(A1)+1)))
Entered as a matrix formula with SHift+Ctrl+Enter
This should work for you:
=INDEX(A2:A4,MATCH(MAX(B2:D4),D2:D4,0))
Hope it's what you are looking for!
It would be nice to use a VLOOKUP but this can only find columns to the right of the match, so to go to the left of a match try this solution, which uses the MATCH() and INDEX() functions:
http://www.excel-easy.com/examples/left-lookup.html
Using your example image create 3 new columns (and then if you want combine them all into 1 by aggregating the formulas)
The formula for colum E is just your MAX function
For F it is this: =MATCH(E2,B2:D2,0). The MATCH() function looks for the value contained in cell E2 (which is the max of B2:D2) in the array B2:D2 which is row A of your company values. The trailing ,0 in the function parameters tells the function to look for the first exact match. It thus returns the column where the max value occurred. You can then use the column to look up the names of the companies:
For G it is =INDEX($B$1:$D$1,1,F2)
I have a large Excel dump from SQL with many columns of data. Two of those columns have different fields with various text values. There are six correct values for the first column and five correct values for the second column. I need to count the accounts (column A) that have both "correct" values.
Well, I just stumbled on this guy:
=COUNTIFS(A:A,"val1",B:B,"val2")
where:
A:A is the first column you have.
"Val1" is the valid value in the first column you want.
B:B is the 2nd column you have.
"Val2" is the valid value in the 2nd column you want.
Unfortunately, that only works if you have 1 value for each column .. and they work more like an AND .. not an OR.
So rather than that, I'd suggest a "helper column":
1) setup your list of valid values somewhere else, and name the lists: "validcol1" and "validcol2"
==IF(OR(ISERROR(MATCH(A2,validcol1,0)),ISERROR(MATCH(B2,validcol2,0))), "", "Valid!")
I solved it through and array that uses "find."
{ =SUM(1*(IFERROR(FIND(b1:b413,"0B,D,E,K,L,S"),0)>0)*(IFERROR(FIND(c1:c413,"0ZA,ZB,ZC,ZF,ZK"),0)>1))}
Note the use of the leading 0 at the start of each set of values.
It's my understanding hard-coding the values into the formula isn't ideal. Anyone have any ideas for that?