I have the following table of two columns:
102-6956821-1091413 1
115-8766130-0234619 2
109-8688911-2954602 3
109-7731824-8641056 4
If I put in the following VLOOKUP:
=+VLOOKUP(B2,B$2:C$5,2)
I get the result of:
1
2
1
1
If I change it to =+VLOOKUP(B2,B$2:C$5,2, FALSE) I get the expected:
1
2
3
4
But why is this? There is an exact match available so why does it need to approximate? If it is, why is it generating the numbers it is? How is it reducing that text value to a number that it is approximating from? Thanks!
Transfer from comment for the sake of an answer:
If your search list (ColumnB) were sorted you would see the results you expect anyway (though in a different order). For speed, VLOOKUP is using a binary search method for which an ordered list is necessary if to achieve meaningful results. There are exact matches only in the first half of the unsorted list (hence 1 and 2 are correct but neither 1 nor 1 is).
Related
I am trying to work through this problem where I have 2 sheets (seen here as 2 sections for simplicity) and I am trying to count how many shipments from sheet 1 were below the SLA target in sheet 2.
The formula I tried was
IF(A21=INDEX(A2:A11,MATCH(A21,A2:A11,0),COUNTIF(C2:C11, ">="&C21))
I have tried multiple iterations of these parameters and have it returning some very inconsistent and totally wrong results. The output I am expecting is
0,0,1,3,0,0
I know this is going to probably be some kind of boolean algebra but I honestly do not understand how that system works. I have tried looking it up but I dont think i am doing it right.
Sample Data
You could use a simple boolean multiplier like this:
=SUM((A21=$A$2:$A$11)*($C$2:$C$11<C21))
This checks if the ID matches A21 and then multiplies these TRUE/FALSE results times a second boolean array that checks if the shipped amounts (C2:C11) are less than the SLA standard C21. NB: If it is really less than or equal, then use =SUM((A21=$A$2:$A$11)*($C$2:$C$11<=C21)). This generates a series of 1's for each value that matches the conditions and then SUM adds those one's up.
Using your example for ID Key 4/Item Name D, you would get:
SUM({FALSE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE,FALSE} * {TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE})
This gets coerced into:
SUM({0,0,0,0,0,1,1,1,0,0})
I did not see something like this in other questions/ forums so hopefully it can be done.
Need to know if values from one table are in another, checking to see if there is a match.
Table 1 in Sheet 1 is used to record "Incoming" data of Part Number and Lot Number.
Table 2 in Sheet 2 is used to record when record is "Outgoing".
Column A is Part Number, B is Lot number in both Sheets. Part number can repeat, but Lot # will not. Trying to find a way to return a Yes/ No or 1,0 if part number and lot number in Sheet 1 exists in Sheet 2 in Column C of Sheet1. I have attached a Snippet example what I am trying to do. This will help me generate info on if an Incoming record has been completed and left (Outgoing). I do not believe vlookup will work and have tried some different permutations of match. Open for other options. Thanks!!
Edit: Lot # does have to ablity to repeat (not often) but with a different corresponding Part Number. Need to know if there is a match with both Lot# and Part Number as in the Incoming record.
Use:
=--(COUNTIFS(Sheet2!A:A,A2,Sheet2!B:B,B2)>0)
If there are matches it will return 1 if not 0
I have a table that I want to find the top X people in each of the different groups.
Unique Names Number Group
a 30 1
b 4 2
c 19 3
d 40 2
e 1 1
f 9 2
g 15 3
I've ranked the top 5 people by number by using =index($A$2:$A$8,match(large($B$2:$B$8,1),$B$2:$B$8,0)). The 1 in the LARGE function I linked to a ranked range so that when I dragged down it changed up the number.
What I would like to do next is rank the top x number of people in each group. So top 3 in group 1.
I tried =index($A$2:$A$8,match("1"&large($B$2:$B$8,1),$C$2:$C$8&$B$2:$B$8,0)) but it didn't seem to work.
Thanks
EDIT: After looking at the answers below I have realised why they are not working for me. My actual data that I want to use the formula with have multiple entries of numbers. I have adjusted the example data to show this. The problem I have is that if there are duplicate numbers then it returns both of the names even if one is not in the group.
Unique Names Number Group
a 30 1
b 30 2
c 19 3
d 40 2
e 1 1
f 30 2
g 15 3
Proof of Concept
Use the following formula in the example above in cell F2 and copy down and to the right as needed.
=IFERROR(INDEX($A$2:$A$8,MATCH(AGGREGATE(14,6,($C$2:$C$8=F$1)*($B$2:$B$8),ROW($A2)-1),$B$2:$B$8,0)),"")
In the header row provide the group numbers. or come up with a formula to augment and reset the group number as you copy down based on your X number in your question.
Explanation:
The AGGREGATE function unlike the large function is an array function without the need to use CSE. As such we can add criteria to what we want to use. In this case only 1 criteria was used and that was the group number. in the formula it was the following part:
($C$2:$C$8=F$1)
If there were multiple criteria we would use either an + operator as an OR or we would use an * operator as an AND.
The 6 option in the aggregate function allows us to ignore errors. This is useful when trying to get the small. It is also useful for dealing with other information that may cause errors that do not need to be worried about.
As this is technically an array operation avoid using full column/row references as they can bog down your system.
The basics of what the over all formula is doing is building a list that match the group number you are interested in. After filtering your numbers, it then determines which is the largest, second largest etc by what row you have copied down to. It then determine what row the nth largest number occurs in through the match function, and finally it returns to the corresponding name to that row with the index function.
Building on all the other great answers.
Because you have the possibilities of duplicate values in each group we need to do this with two formulas.
First we need to get the numbers in order. I used the Aggregate, but this could be done with the array LARGE(IF()) also:
=IFERROR(AGGREGATE(14,6,$B$2:$B$8/($C$2:$C$8=E$1),ROW(1:1)),"")
Then using that number and order we can reference, we can use a modified version of #ForwardEd's formula, using COUNTIF() to ensure we get the correct name in return.
=IFERROR(INDEX($A$2:$A$8,AGGREGATE(15,6,(ROW($B$2:$B$8)-ROW($B$2)+1)/(($C$2:$C$8=F$1)*($B$2:$B$8=E3)),COUNTIF(E$2:E2,E3)+1)),"")
This will count the number in the results returned and then bring in the correct name.
You could also solve this with array formulas - to filter a group whose name is stored in E1, your code
=INDEX($A$2:$A$8,MATCH(LARGE($B$2:$B$8,1),$B$2:$B$8,0))
would then be adapted to
=INDEX($A$2:$A$8,MATCH(LARGE(IF($C$2:$C$8<>E1,-1,$B$2:$B$8),1),$B$2:$B$8,0))
Note: After entering an array formula, you have press CTRL+SHIFT+ENTER.
Thank you to everyone who offered help but for some reason none of your methods worked for me, which I am sure was to do with the quality of my data. I used an alternate method in the end which is slightly convoluted but seemed to work.
=IF($C2="1",RANK($B2,$B$2:$B$8,1)+ROW()/10000,-1)
Essentially using the rank function and adding a fraction to separate out duplicate values.
First off let me say thanks and sorry for potential poor formatting. I tried to make it as straightforward as possible, but I am not sure how to insert a table into this box.
I have the following two columns side by side in Excel, in columns A and B.
1 INIT
2 INIT
3 INIT
4 INIT
4 UNWIND
3 INIT
5 INIT
1 UNWIND
In column C, I would like to place a 1 if the numbers in the first columns are the same AND those numbers have both an INIT and the UNWIND. Thus the final solution would look like this:
1 INIT 1
2 INIT 0
3 INIT 0
4 INIT 1
4 UNWIND 1
3 INIT 0
5 INIT 0
1 UNWIND 1
Note in the example above, even though 3 showed up in column A twice, a zero was placed in column C because the second "3" had "INIT" in column B, not "UNWIND".
I was thinking of using a combination of If statements with Match, etc., but I'm not sure how to dynamically complete the task, since the range over which you are searching will change (all rows of the column, excluding the row you are currently in). In this example, for row 1, you would simply search all rows below it. However, for row 2, you would want to search the row above it, and all those that follow, and so on.
Any help is greatly appreciated.
Thanks
It looks like you're trying to test to see if any number in column A has both an "INIT" and "UNWIND" value. The simplest solution here is COUNTIFS with an AND.
=AND(COUNTIF(A:A,A1)=2,COUNTIFS(A:A,A1,B:B,"INIT")=1,COUNTIFS(A:A,A1,B:B,"UNWIND")=1)
Of course, note that the formula I provided will count ALL of the columns, and requires exactly two matching rows with one INIT and one UNWIND. And it'll return a boolean true or false rather than a 1 or 0, but you should be able to cast a boolean to whatever value easy enough.
(And if possible, use Tables post Excel 2007. They make the formula FAR easier to read.)
Alternate formula:
=--AND(COUNTIFS(A:A,A1,B:B,{"INIT","UNWIND"}))
This is a doubt that arose in my workplace, and it should be pretty straightforward.
We have two columns of numbers, say:
1 1
1 2
2 1
2 2
And we want to get the number of rows that have equal numbers (2), without a helping column for each comparison. We can't get a working matrix operation (wich is the way we think correct). Any ideas?
Thanks in advance!
Three more to pile on here:
Condensed array function:
{=SUM(--(A1:A10=B1:B10))}
Same function, but wrapped in a SUMPRODUCT rather than an array function:
=SUMPRODUCT(--(A1:A10=B1:B10))
Ignores blanks:
=SUMPRODUCT(--(A1:A10=B1:B10)*NOT(A1:A10="")*NOT(B1:B10=""))
We got it using:
{=SUM(IF(A1:A10=B1:B10;1;0))}