Matching two columns and returning a third with data in between - excel

I have tried using VLOOKUP, INDEX, and IF statements but none have quite worked.
What I want to do is match serial numbers and return a stock number, but there is data between the columns that I need to keep. Also there are only 60 serials that I am looking to link with stock numbers and 1200 serials with stocks to search through. So like this:
A B C D E F
1 description serial location Stock # Stock # Serial
2 info aaa 1 E1 zzz
3 info bbb 1 E2 sss
4 info ccc 2 E3 aaa
I am trying to put the formula in D, search and match column B with F and return column E to D.

Not exactly sure what is going on with the different quantities, but in D2 and copied down to suit:
=IFERROR(INDEX(E:E,MATCH(B:B,F:F,0)),"")
seems worth a try. VLOOKUP is not a good choice here, in part because the related field is to the left of the search term.

Related

Sum values using lookup table, where lookup values are a list of values with comma delimiter

I am trying to sum values based that equal a lookup value. However, that value is actually a list of values delimited by a comma. Below is an example of what I mean.
Suppose I have raw data in the form of sheet1 below:
Sheet1:
A
B
1
ID
VALUE
2
A
30
3
A
50
4
A
20
5
B
10
6
B
20
7
C
70
8
C
40
9
D
30
10
E
50
11
F
20
12
F
30
13
G
10
And I have a look table that groups all IDs by their respective teams, as per sheet2 below.
Sheet2:
A
B
1
TEAM
IDS
2
Red
A, B
3
Blue
C, D
4
Green
E, F, G
And I want to create a report where the user can select the team name, and the sum of the values in sheet1 will aggregate based on the selection, as per the following example. So the user would select "Green" in cell B1 and it would return the sum of values that correspond to E, F, and G in sheet1.
Report:
A
B
1
Select Team:
Green
2
Sum:
110
I have searched all over for a solution to this and was able to find something similar. I tried to repurpose the formula for my data but couldn't get it to work because I think that solution dealt with numbers rather than text.
Excel: Perform a SUMIF where the criteria is a comma-delimited list
Any suggestions would be greatly appreciated!
Edit: Just want to add that I realize I could first parse out the IDs in sheet2, however I'm looking for a formula that can bypass that as my real dataset is quite large and parsing out the IDs under each team would explode the number of rows.
A variation of #JvdV solution on the linked question:
=SUMPRODUCT(SUMIFS(Sheet1!B:B,Sheet1!A:A,FILTERXML("<t><s>"&SUBSTITUTE(VLOOKUP(Sheet2!F1,Sheet2!A:B,2,FALSE),",","</s><s>")&"</s></t>","//s")))
Note, this only works with Excel 2013 or later and only on PC. FILTERXML is not available on Mac or prior to 2013.
If Mac or prior to 2013:
=SUMPRODUCT(SUMIFS(Sheet1!B:B,Sheet1!A:A,TRIM(MID(SUBSTITUTE(VLOOKUP(F1,Sheet2!A:B,2,FALSE),",",REPT(" ",999)),(ROW($ZY1:INDEX($ZY:$ZY,LEN(VLOOKUP(F1,Sheet2!A:B,2,FALSE))-LEN(SUBSTITUTE(VLOOKUP(F1,Sheet2!A:B,2,FALSE),",",""))+1))-1)*999+1,999))))

Excel Count rows where value in Column A has a duplicate in column B and that duplicate's other value in Column A equals something

Given the table below:
A
B
C
D
1
happy
1-veggies
GHF
1
sad
1-veggies
HGF
2
angry
1-veggies
GHG
2
sad
1-veggies
FGH
3
sad
1-veggies
HGF
4
moody
2-meat
FFF
4
sad
2-meat
HGF
5
excited
2-meat
HGF
I need to count the number of rows where C="1-veggies", B="sad", A has a duplicate within A and whose alternative rows in A have a value in D = "GHF" or "FGH".
The result should be 1 based on the second row.
The second row has B= "sad", C = "1-veggies", A has a duplicate within A, whose value is "1" and the 1st row, also with A = "1" has a value in D = "GHF".
I already have a formula as follows:
=SUMPRODUCT((B1:B8="sad")*(COUNTIF(A1:A8,A1:A8)>1)*(C1:C8="1-veggies")*(D1:D8="GHF"))
However, it isn't able to check the 1st row nor does it check the necessary OR statement on column D.
I don't know how to accomplish either task. Thank you.
Add some more COUNTIFS():
=SUMPRODUCT((B1:B8="sad")*(COUNTIF(A1:A8,A1:A8)>1)*(C1:C8="1-veggies")*(COUNTIFS(A1:A8,A1:A8,B1:B8,"<>sad",D1:D8,"GHF")+COUNTIFS(A1:A8,A1:A8,B1:B8,"<>sad",D1:D8,"FGH")>0))
Basically you want to select rows where C="1-veggies", B="sad" and join them to rows where D = "GHF" or "FGH", but with a condition that the value in column A is equal in both but the row number is unequal. This might be a good use of Power Query for users who are expert in this, but using formulas is problematic because of the limitations of countifs (has to be a range). A workaround if you have Excel 365 would be to use some filters followed by countifs:
Column E
=FILTER(A1:A8,(B1:B8="sad")*(C1:C8="1-veggies"))
Coumn F
=FILTER(ROW(A1:A8),(B1:B8="sad")*(C1:C8="1-veggies"))
Column G
=FILTER(A1:A8,(D1:D8="GHF")+(D1:D8="FGH"))
Column H
=FILTER(ROW(A1:A8),(D1:D8="GHF")+(D1:D8="FGH"))
Then
=SUM(COUNTIFS(E1#,G1#,F1#,"<>"&H1#))

Ignore text values in subtotal function

Excel-Sheet:
A B C D E
1 1.200
2 Product A 500
3 Product B 400
4 Product C OK
5 Product D #NA
6 Product E 300
7
8
In the above table I have list of products in Column A and some data about the products in Column B.
In Cell B1 I want to calculated the subtotal of Column B using =SUBTOTAL(9,B2:B6).
However, now I have the issue that Column B not only consists of numbers.
It can also have the data type text (OK, NA). Therefore, the result in Cell B1 currently is #NA.
Is there any kind of formula that I could use so only the number data is considered and the result is 1.200 as in the table above?
Please note:
This function =AGGREGATE(9,6,B2:B6) won't help me because I want to filter the list later on so I need to go with the SUBTOTAL.
Use 7 as the second criterion in AGGREGATE instead of 6 as it will also exclude hidden rows:
=AGGREGATE(9,7,B2:B6)
You can solve this, combining the Excel worksheet functions =Value() and =IfERROR():
The function =Value() gives the value of a number, and in case of text it gives an error.
=IfError() can be used to give 0 in that case.
So, imagine you have following situation:
Column A Column B Column C
1 =Value(A1) =IfError(B1;0)
3.5 =Value(A2) =IfError(B2;0)
AB =Value(A3) =IfError(B3;0)
abc10 =Value(A4) =IfError(B4;0)
This gives following results:
Column A Column B Column C
1 1 1
3.5 3.5 3.5
AB #Value 0
abc10 #Value 0
You can simply take the sum of column C.
So this is based on the summary in B1.
=SUM(IF(ISERROR(B2:B6),"",B2:B6))
You need to push Ctrl+Shft+Enter for this to work.
Hope it helps.

Sort list by the difference between two values

I have the following Excel spreadsheet:
A B C D
1 Budget Actual Sort by Variancy (descending)
2 Product A 500 250 Product F
3 Product B 900 800 Product D
4 Product C 300 450 Product C
5 Product D 400 600 Product B
6 Product E 700 300 Product A
7 Product F 150 900 Product E
As you can see in Column A I have listed different products and in Column B I have their budget value and in Column C the actual value.
Now, I want to list those products based on their budget-actual-variancy in Column D in a descending order (starting from the highest positive variancy).
The only formula which comes in my mind is =LARGE(B2:B7,1) but it only sorts the products by the budget values (Column B) or actual values (Column C). Not by the difference between the two values.
Do you know any formula which I can use to sort the products in Column D based on their variancy?
Please note:
I know I could add a helper column in which I calculate the differences between Column B and Column C and then go with the LARGE function on this helper column but I am looking for a solution without such a helper column.
If one has SORTBY()(Currently only available with Office 365 insiders) then put this in D2 and it will spill automatically:
=SORTBY(A2:A7,B2:B7-C2:C7,1)
You can use the following (even when there are duplicate variances):
Formula in D2:
=INDEX($A$1:$A$7,LARGE(INDEX(($C$2:$C$7-$B$2:$B$7=AGGREGATE(14,3,$C$2:$C$7-$B$2:$B$7,ROW(1:1)))*($A$2:$A$7<>D1)*ROW($A$2:$A$7),),1))
Drag down.
In case of duplicate variances it will grab the last value in column A that represents that variancy and has not been featured in column D as yet.

Find duplicates with a suffix in excel and keep results

I have a spreadsheet with a list of items in one column (A) and in column C shows the total sold. I'm trying to find all the items within column A.
The issue is, some items are the same, only they have a suffix, mostly separated by a -. The values in column C would be different as well.
Example:
ABC = 5
ABC-123 = 3
ABC-543 = 2
I'm looking to identify only 123 and then combine all the values, so that it will show ABC and 10 as the total.
I've looked around how to remove the duplicate suffix, but have so far failed to find a method when trying to add the total values.
Many thanks
do you mean the data you have looks like this:
column A column B column C
ABC 5
ABC-123 3
ABC-543 2
if so, you can select column A then go to data then text to columns then delimited select other by putting - sign, next and finish.
result must be:
column A column B column C
ABC 5
ABC 123 3
ABC 543 2
then you can =sumifs(C:C;A:A;"ABC") (keep in mind that column B must be empty)
if you have ABC-123 = 3 in the same cell as a text, then you can do:
=IF(SEARCH("ABC";F3);RIGHT(F3;LEN(F3)-FIND("=";F3)-1);"")
where F3 is equal to ABC-123 = 3 The formula above searches fo ABC and gives you a value after = sign, no matter how long this value is. If there is no ABC it will return an error.
if there is no need to look for ABC then just use:
=RIGHT(F3;LEN(F3)-FIND("=";F3)-1)
I hope this helps. I cannot comment, so ask if you have questions.
Best - AB

Resources