How do I add multiple criteria to this index match formula, which I pulled from a previous post, here: Use of INDEX MATCH to find absolute closest value.
=INDEX(B4:B10,MATCH(TRUE,INDEX(ABS(A4:A10-B1)=MIN(INDEX(ABS(A4:A10-B1),,)),,),0))
The formula above uses only one criteria while I need to use three Sample
I'm trying to use the same formula for a sample problem. I want to match cols B & D in table A to cols A & B in table B using the closest number in col C (table A) to output into table A, the corresponding col D from table B.
If you have an aversion to using Array Formulas [or if you would prefer not to for legitimate reasons, of which there are some], my recommendation is that you use a helper column to create a new unique ID.
For example, assume column A contains client Country, column B contains client State/Province, and column C contains client City. You would need all 3 to identify the geographic location of a client. So, create column D, as follows [starting in D2, and copied down]:
=A2&B2&C2
This will create a new field which shows CountryStateCity. If you want this to be displayed anywhere, you may want to add commas, as follows:
=CONCATENATE(A2,", ",B2,", ",C2)
Note that CONCATENATE is effecively the same as using '&'.
Now to search and find the client name in column E, which matches the geographic location [assuming that there's only 1 per city, but this is just an example anyway], do as follows:
=INDEX(E:E,MATCH("USA, Michigan, Detroit",D:D,0))
Related
I have two sets of data in excel, set 1 is the raw data, and set 2 is a bridge table. The desired output is also added. How should I prepare for this formula.
set 1:
set 2:
output expected:
Here, a solution that assumes a variable number of headers and no specific pattern in the column names. Assumed no Excel version constraints as per tags listed in the question. In cell H1, put the following formula which spills the entire result all at once:
=LET(in, A1:F5, lk, A8:B12, header, DROP(TAKE(in,1),,1), A, TAKE(lk,,1),
B, DROP(lk,,1), data, DROP(in,1,1), REDUCE(TAKE(in,,1), UNIQUE(B),
LAMBDA(ac,bb, LET(f, FILTER(A, B=bb),values, CHOOSECOLS(data,XMATCH(f, header)),
sum, MMULT(values, SEQUENCE(ROWS(f),,1,0)), HSTACK(ac, VSTACK(bb, sum))))))
Here it the output:
We use LET function with two input ranges only: in, lk, so the rest of the names defined depend on such range names. It makes the formula easy to maintain and to adapt to your real scenario.
Using DROP and TAKE we extract each portion of the input ranges: header, data, A, B (columns from the second table). We use REDUCE/HSTACK pattern to concatenate the column of the result on each iteration. Check my answer from the question: how to transform a table in Excel from vertical to horizontal but with different length for more information.
We iterate by unique values of B and for each value (bb) we select the column A values (f). We use XMATCH to select the corresponding index columns from header (it doesn't include the date column). We use CHOOSECOOLS to select the corresponding columns from data (values). Now we need to sum by column, and we use MMULT for that. The result is in sum name. Finally, we use HSTACK to concatenate the selected columns one each iteration, including as header the unique values from B.
Note: Instead of MMULT function, you can use the following array function, it is a matter of personal preferences:
BYROW(values, LAMBDA(x, sum(x)))
You could try SUMIFS with the wild card character for each row. For example, for the first column, put the following formula and drag it down.
=SUMIFS($B2:$F2,$B$1:$F$1,"=A*")
Then do the same thing for the other columns, e.g. for column B:
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?
Player Data
Team Data
Example Outcome
Currently I have two tables: The first, with all player data in the basketball conference (Pts, Ast, BLks, Rebs, etc) and the second, with all the team data in the conference (Pts, Ast, BLks, Rebs, etc) the difference being the team table is the totals for the complete team. In a separate table I would like to be able to compute some additional values for each player based on both his basic stats and the teams total stats. In order to do this I believe I need to match first a player to a team using a team Name column and if the player's team name matches the team name totals then use corresponding values in the rest of the columns within that team name row. Then repeat this for each player in the conference.
I have tried using the MATCH and INDEX but do not believe they are what I am looking for as once I match the team names I need to use the entire rows worth of data within a formula.
Any help/guidance would be greatly appreciated
If I were you, I wouldn't create a new table for that, just add the new data you want in new columns in the players table. That way you can do this:
If your new data's column headers have the same order as the column headers you're extracting data from of the teams table, then Calculate d and put this formula in the first cell in the first new column you added to the players table, and copy it to the rest of the table.
=INDEX(TeamsTable, MATCH(TeamsColumnInPlayersTable, TeamsColumnInTeamsTable, 0), COLUMN() + d)
Where d is the difference between the column number of the cell you're adding this formula to and the column number of the of the column you want the data extracted from in TeamsTable.
For example, if you want to add new data in columns(E, F, G, H) in the players table, and these columns are extracting data from columns (L, M, N, O) in teams table respectively, then d = Num(L) - Num(E) = 12 - 5 = 7.
However, if they're not in the same order then your formula becomes this:
=INDEX(TeamsTable, MATCH(TeamsColumnInPlayersTable, TeamsColumnInTeamsTable, 0), col)
Where col is the number of the column that has the data you want extracted from. Put this formula in the first cell of each new data column and copy downward.
I have a list of values with multiple columns. One of the columns contains values under the format "X-Y" (values are not numerical. There are no other hyphens/"-"s in X or Y. The only hyphen is the separator). I would like to create a new column that contains specific values depending on what X is in this one column.
For example, if X = 'egg', I want it to print out 'bacon' in the column next to it. If X = 'duck', I want the value in the column next to it to be 'bird' instead.
If column A held value egg-quack, I would want the column B next to it to print out bacon. If column A held value egg-duck, I would still want column B to contain the value bacon. If column A held value duck-duck, column B would contain the value bird.
I hope this is clear. How would I be able to go about doing this?
I'm not too familiar with data handling in general, so if there are other more effective methods other than VBA, I'm also willing to look into that.
Thank you!
You can use VLOOKUP for this, with FIND to locate the hyphen:
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