Lookup a value that matches a key in one column then apply that as a key to return a value from a third column - excel

I have values in columns G and N that have the same values, but not in the same order, so if column G and N matches, then return column L to column A. I am getting the wrong values from column L in column A.
What other information is needed besides formula below?
=IFERROR(VLOOKUP(N2,$G$2:$N$413,6,FALSE),"")
Col a Col b Col G Col L Col M Col N
ID CoID Items ItemsID ParentID Items1
45 1 Apple 45 1 Apple

Since you are trying to find the ColumnL value in the same row as you find the ColumnN value I’d suggest an INDEX MATCH combination – similar to VLOOKUP but more powerful (eg can ‘look to the left’, which VLOOKUP can’t).
=IFERROR(INDEX(L:L,MATCH(G2,N:N,0)),"")
MATCH looks for the position where G2 is found in ColumnN so that is the row number for the ColumnL value you want returned.

Related

Searching a column for a string in one array, and returning a value that corresponds to that array

I am going to do my best to describe this.
I want to search column C for any of the strings contained on a different sheet in column A, and if/when one of those strings is found, i want to return the column B that corresponds to the found string.
For example:
Sheet 1:
Column A
Column B
Column C
project 1
2/15/19
Status is Red, because....
Project 2
4/12/20
RAG- Green, PTG is....
And on another sheet I have common ways to describe their statuses in Column A, and in Column B, a simple letter R, A, G or NS (Not started) if no other common status is found.
Column A
Column B
Column C
Status is Red
R
Rag- Green
G
How can I Search Column C for a value on Column A (on a different sheet) and return column B in Column D on the original sheet?
Results should look like
Column A
Column B
Column C
Column D
project 1
2/15/19
Status is Red, because....
R
Project 2
4/12/20
RAG- Green, PTG is....
G
This may be a bit of an extended function and depends on how many rows you have in the second sheet.
You can hard code it with
=IF(ISNUMBER(SEARCH("Red",C2)),VLOOKUP("Status is Red",Sheet2!$A$2:$B$3,2,FALSE),IF(ISNUMBER(SEARCH("Green",C2)),VLOOKUP("RAG - Green",Sheet2!$A$2:$B$3,2,FALSE),"NS"))
Or use the more dynamic:
=IF(ISNUMBER(SEARCH(Sheet2!$A$2,Sheet1!C2)),VLOOKUP(Sheet2!$A$2,Sheet2!A2:B3,2,FALSE),IF(ISNUMBER(SEARCH(Sheet2!$A$3,Sheet1!C2)),VLOOKUP(Sheet2!$A$3,Sheet2!$A$2:$B$3,2,FALSE),"NS"))
Explanation
SEARCH(find_text,within_text) - returns the index of where the substring begins
ISNUMBER(value) - returns TRUE if a number, FALSE if not.
VLOOKUP(lookup_value,table_array,col_index_num,[range_lookup]) - finds the value within the array and returns the corresponding value in the specified column.
$X$Y - the dollar signs stop the values from changing when you use ctrl+d or ctrl+r to fill multiple cells
So to break it down:
IF (search returns an index)
THEN VLOOKUP (find this value and return the corresponding value from this column)
ELSE (repeat above as needed)
ELSE ("NS")

Is there a way to have column O pull values from column F is J through L match A through C

I have column A as city code, B as Origin City,St , C as city code, D as Destination city,St. I then similar date in I through L with Carriers that haul those lanes in N. If a row in the I through L match a row in A through D I need the value of F place in the O column in the corresponding row.
I am trying to paste an image of the Excel grid, but I need column O to pull the value from column F from the row that has the values from A to D that match the data in a row in I to L.
Expected Result in Grid
You can use a combination of index() with match()
So, to fill Column O, this should work:
=INDEX(F$40:F$60,MATCH(I40&K40,G$40:G$60,0))
I have assumed that you can add a helper column in G, which is =A40&C40 dragged down.
I have also assumed that the combination of the two numbers in cols A & C are unique when combined.
If that is not the case then you will need to add col B, so the helper column becomes =A4&B40&C40 and the match will be I40&J40&K40.
Tested this on 3 values, as you don't give data I can get to.

scan Excel column based on another column value

I want to check one entire column with value in another column and then assign a value in another column value to matching row cell.
Eg-
A B C D
1 10 X
2 3 Y
3 2 Z
4 11 K
What I want to do is take one value at a time from column A eg 1 and then scan through Column B if matches the Column A (value 1) then assign x to that row under D. eg if we check A3 ( value 2) with column B and found 2 is on B4 then D4 = Z. Like this I want to check all values in column in A against column B assign relevant vale from column C to Column D
How can I do this, can someone please help me.
Thanks.
Try:
= IFERROR(INDEX($C$2:$C$5,MATCH(A3,$B$2:$B$5,0)),"no match")
See below.
Try:
=IFERROR(VLOOKUP(A1,$B$1:$C$5,2,0),"")

Sum of multiple columns if they match

I have this table of data:
A B C D E
003B1016 1 003G1016 1 003B1016
003G1015 1 003G1391 2 003G1015
003H0121 4 003H6208 2 003H0121
003H6209 1 003H6209 1 003H6209
I want to sum B+D if A and C are identical , how would i do that?
I have another 32000 rows of data. :) Thanks for the help
Put this in cell E1 and copy down:
=IF(A1=C1,B1+D1,"")
This says - if A = C, then add B+D. Otherwise, return blank "".
EDIT for new requirements
In order to add all amounts from column B where column A matches the current row and from column D where column C matches that row, where the row in column A exists anywhere and the row in column C exists anywhere, do the following formula in E2 and drag down:
=IF(ISERROR(MATCH(A2,A$1:A1)),IF(ISERROR(MATCH(A2,C:C,0)),"",SUMIFS(B:B,A:A,A2)+SUMIFS(D:D,C:C,A2)),"")
This says: look above the current row in column A - have we seen this item before? If no, continue with the formula. If yes, ignore, to avoid double counting. Then, Look at all of column C - does the value in the current row of A occur anywhere in column C? If no, then don't add anything. If yes, Add all items from column B where column A matches the current row, and add all items from column D where column C matches the current row.

Count unique values from columnA if adjacent columnB meets a criteria and is not equal to a second criteria

This is my first post and hopefully I can explain this issue clearly.
Assuming the following raw excel table:
ColumnA ColumnB ColumnC
1 W A
1 E A
1 W B
1 E C
1 E D
1 E E
1 W E
1 E F
Count of unique E in ColumnB 5
Count of unique W in ColumnB 3
Task:
1) In counting unique values in ColumnC, count unique values that have a value of E in ColumnB.
2) In counting unique values in ColumnC, count unique values that have a value of W in ColumnB, taking into consideration that if an item in ColumnC has both E and W in ColumnB, it should only be counted for assumption 1 above. Only items in ColumnC that have only W in ColumnB should be included in this count.
As shown in my results, the count for items that have E in ColumnB is 5 which is correct. However, the count for items that have W in ColumnB is returning 3, but it should only return 1 because {1, W, B} is the only row where ColumnC item B has only a W in ColumnB.
The excel formula I have used for both counts are below:
Count for E
=SUM(IF(FREQUENCY(IF($A$2:$A$9="1",IF($B$2:$B$9="E",MATCH($C$2:$C$9,$C$2:$C$9,0))),ROW($C$2:$C$9)-ROW($C$2)+1),1))
Count for W
=SUM(IF(FREQUENCY(IF($A$2:$A$9="1",IF($B$2:$B$9="W",MATCH($C$2:$C$9,$C$2:$C$9,0))),ROW($C$2:$C$9)-ROW($C$2)+1),1))
Note the formula needs to be entered with Ctrl+Shift+Enter
How can I count for W and exclude rows from ColumnC that have both E and W in ColumnB?
Thanks in advance.
Try using this formula:
=SUM(IF(FREQUENCY(IF($A$2:$A$9="1",IF($B$2:$B$9="W",IF(COUNTIFS($A$2:$A$9,1,$B$2:$B$9,"E",$C$2:$C$9,$C$2:$C$9)=0,MATCH($C$2:$C$9,$C$2:$C$9,0)))),ROW($C$2:$C$9)-ROW($C$2)+1),1))
also using CTRL+SHIFT+ENTER
The additional COUNTIFS function gives you the extra functionality you need because that checks if there are additional rows with "E" against the relevant column C values
...or an alternative approach would be to count all different values from column C (assuming 1 in column A), and just subtract your "Count for E", so if that "Count for E" formula is in B12 use this array formula
=SUM(IF(FREQUENCY(IF($A$2:$A$9="1",MATCH($C$2:$C$9,$C$2:$C$9,0)),ROW($C$2:$C$9)-ROW($C$2)+1),1))-B12

Resources