How to search for multiple values across columns - excel

I have a table (Table 1) with multiple names per row i.e. Column Structure is (Unique ID, Name 1, Name 2, Name 3, etc). I then have another table (Table2) which is just a list of names in one column (Name x, Name y, Name z, etc). I am trying to identify which rows in Table 1 have a column with a name in Table2 and then return whichever name is matching. It does not matter if there are multiple matches, I only care if there is a match.
My current thinking is to use the Index(match) function, but I am unsure if there is a way to input the list from table 2 into the "Lookup Value" spot of the match portion. Does anyone know if this is possible or if there is another way to get what I am looking for?

Related

VLOOKUP for matching employee id

I have 2 spreadsheets I am working with. They both contain tons of data and numerous columns. Spreadhseet1 contains columns ssn_id and employee_id. Spreadsheet2 contains column ssn_id and does not have employee_id. I want to use VLOOKUP to create another column that provides the employee_id of the employee based on their ssn_id.
I used the code below:
=VLOOKUP(L3,[spreadsheet1.xlsx]spreadsheetname!$A$2:$Q$99999, 3, FALSE)
L3 is the column in spreadhseet2 that contains the ssn_id, I used that as the lookup value because I am using it to get the employee_id. In spreadsheet1, The column Q contains the ssn_id, hence why I set the range from A to Q. In spreadsheet1, the 3rd column (column C) contains the employee_id, which is why I set the column index number to 3. This is how i feel like it should be written, but it keeps on providing me #N/A values. Can anyone let me know what I am doing wrong?

Looking for assistance in Excel to return X number of values for a vlookup

I have a dataset that includes the following information:
Storage Location Tab
Column A - product identifier (can be repeated)
Column B - storage location (unique)
Quantity needed tab
Column A - product identifier
Column B - # of products needed (X)
I'm looking to use a vlookup type of equation to return the first X number (# of products needed) of storage locations results of the product identifier (as vlookup by default would only show the first result)
Well, like others have said the built in filtering is the easiest way to do this. But, if you MUST only return the first x items, you can do the following which will require a tiny change to your data:
1.) Add one additional column in your "Storage Location Tab" to keep track of the item index ( for example if it is the 3rd item with product identifier = 5 in column A, you assign it item index 3)
You can do this with the following function on C2 and just drag it down: =COUNTIFS($A$2:A2,A2).
This formula will essentially just count how many rows have the same product ID above it (including itself).
2.) Next, In your other Tab where you want to return x results, create an "item index" also. This is to for searching purposes and to keep track of the item you want to extract from the table. If you want to pull the first 4 items you essentially need to do a look up for items (1, 2, 3,& 4)
With those additional fields you can use a combination of the "index" and "match" functions to do a search on 2 criteria "Product identifier" and "Item index" to get your storage locations.
=INDEX(B:B,MATCH(1,(A:A=$F$2)*(C:C=E3),0),0)
Here is what my excel looks like to assist with a visual:
My Excel Sample
If you want to add some error checks and make it so it does not return anything for indexes greater than your "# of products needed" then you can wrap the above formula with an if statement and an if error statement. The below will return an empty space if the match returns no results or the item index is larger than the # of products needed.
=IF($G$2>=E3,IFERROR(INDEX(B:B,MATCH(1,(A:A=$F$2)*(C:C=E3),0),0),""),"")

In excel, is there a way to pull specific data for a report besides a VLOOKUP?

So I want to pull a variety of different data from several reports into a Master File of sorts based on the unique identifier present within each report. I wanted to use a VLOOKUP for this feature, but I wanted to know if there's another way to gather the specific reports and have a easier way to update the data accordingly if new data exists in the reports in the future, as well as a way to pull the file number in an adjacent column. Thank you for understanding and for any advice/ help.
Here is an example of INDEX & MATCH
VLOOKUP only works when the common column in both the table is on the left side of the desired values column.
Now for more powerful lookup function you can use INDEX & MATCH functions.
To get the desired result you have to input these values in INDEX - INDEX(Table, Row, Column)
MATCH takes 3 values - MATCH(Cell, Column, [-1, 0, 1]) ---- Here 0 is used to find the exact match
Now if you combine the both functions you can replace the Row of INDEX with the MATCH function.
It will be like this - INDEX(Table, MATCH(Cell, Column, 0), Column)
My formula in the sheet is INDEX(I:J, MATCH(D2, J:J, 0), 1)
Here I have used 1 as the Column of INDEX because I wanted the values of GTIN-13.

Vlookup/index on 2 sheets and multiple values

Sheet 1:
Column A: email
Column B: name
Column C: action
Sheet 2
Column B: name
*there are dulpicate names in sheet 1, so each name could have different action and email.
**there are some names in sheet 2 that are not in sheet 1
***there are over 1000 rows.
How do i return the values in sheet2 such that i have the emails, common names and action tgt. Horinzontally.
First, you need an additional column in Sheet1 which counts the occurrences of of each name. Second, in Sheet2, you need to match a name and its occurrence within Sheet1.
The picture below, shows (on a single sheet) an arrangement that you might want to adapt.
In my example I have allowed up to 5 email/action pairs per name, though the solution can obviously be adapted to the requirement of your data.
The solution uses a COUNTIF() function in the "input" table to generate the occurrence number of each name.
In the "output" table, the 5 helper columns identify the row number of the input table matching to the 1st, 2nd,... occurrences of the name, with a zero indicating no match. The SUMPRODUCT() function generates this row number. The remaining columns simply pick out the appropriate email/action from the input table.
The helper columns can be avoided in the "output", but this would be at the expense of replacing the single cell references such as G2 in =IF(G2>0,INDEX($B$2:$B$9,G2),"") with the corresponding SUMPRODUCT() expression. The IF() is necessary because the INDEX() function has a peculiar behaviour when its second argument equates to zero.
Getting the correct formula for the first row of Email/Action pairs in the output table (range L2:U2) in my picture is a bit tedious and there are ways around this (based on using the COLUMN() function to calculate the appropriate helper column number). However, the solution is intended to be something to be built on so I have kept it simple.
The solution assumes that each email/action pair in the input will be kept distinct in the output. So if a name in the input has two (or more) email/action pairs which have a common email, the solution does not combine the two actions against that common email. It is possible to do this but it will require additional information to be added to the "input" table - namely the occurrence of actions associated with a specific name/email combination.

Filtering Dataset by values in one column

So I have an excel dataset of participants that are possibly eligible to partake in a study that consists of their names, age, telephone number, etc... like:
Name | Age | Phone | Email | Address | Studies Participated in
I also have a column of names of participants that are eligible for a new study; it is a subset of the data in the name column.
What I need to do is select all of the participants whose names are in the subset column, and copy and paste all of their information in all of the columns into new columns.
I have tried something like, selecting an empty column and using =IF($Name-column = $Subset-column, First-Column:Last-Column, "") But this only checks if the name in each cell of the Name Column matches the name in the Subset column. What I need is something that checks if any of the names in the Name column match those in the Subset Column, and if they do, then to copy that row to a new worksheet.
Using a VLOOKUP should do the trick.
In an empty column next to the name table, you would want to enter a set of formulas something like:
=IFERROR(VLOOKUP(<name_from_current_row_of_name_table>,<subset_column_range>,1,FALSE),0)
Then you can apply a filter to the name table and set a condition to exclude the 0's in the new column. Copy the filtered data to the new sheet.
You can Index all of your data and then Match rows to the subset names and pull over each column.
For example, it would look something like this:
=INDEX(All!A1:F4,MATCH(Subset!A2,All!A1:A4,0),2)
Let's break this down:
The index function takes the following arguments:
Index(Array, Row_Number, Column_Number)
The array will be all the data you have, the row number we'll use a match function (below) to find which row to get data from, and the column number represents which column from the index to pull information from (we'll keep incrementing this to get all the columns).
To return the correct row, we'll use match
Match(Lookup_Value, Lookup_Array, Match_Type)
For lookup value, we want to point it to the current row of the subset list, the lookup array will be all the names available from the index we defined previously in the master list, and the match type will equal 0 (for exact match)
Take a look at this excel document

Resources