I am working on a hiring trends report and have an Excel table with multiple entries per ID/individual (as several individuals have left and been rehired over years). The table looks something like this:
WORKSHEET: SHEET1
A B C D
ID Name Location Hire Date
1122 Karen Chicago 01/01/2018
1038 Tom Chicago 05/22/2016
2845 Angel Pittsburgh 11/15/2016
1122 Karen New York 10/08/2013
4992 Mallory Seattle 09/14/2015
2845 Angel Pittsburgh 07/21/2011
1122 Karen Pittsburgh 08/22/2011
I have created a new table with only one entry per person and their most recent hire date. The next step is to populate the table with location data based on the person's ID and specified hire date.
My approach was to use an INDEX-MATCH expression with two match statements (one for ID and one for hire date):
=INDEX('SHEET1'!$C$2:$C$2000,
MATCH('SHEET2'!A2,'SHEET1'!$A$2:$A$2000,0),
MATCH('SHEET2'!D2,'SHEET1'!$D$2:$D$2000,0))
The first row where I enter the expression retrieves the correct location data. However, when I attempt to populate the remaining rows in that column, I get a #REF! error, as illustrated below.
WORKSHEET: SHEET2
A B C D
ID Name Location Hire Date
1122 Karen Chicago 01/01/2018
1038 Tom #REF! 05/22/2016
2845 Angel #REF! 11/15/2016
4992 Mallory #REF! 09/14/2015
I've tested each INDEX-MATCH expression separately (first testing for a match only on ID and then testing for a match only on hire date). Each one works separately, and as shown above, it does work for the first row--it just will not autofill for other rows. I've also checked SHEET1 and each individual definitely has the correct matching criteria on SHEET2 for referencing.
Can anyone help with either suggesting a way to fix my expression or an alternative way to retrieve the location data based on two criteria? Thanks in advance!
The third argument to INDEX is the column number, which is why you get a #REF error. You can use LOOKUP instead:
=LOOKUP(2,1/('SHEET2'!A2='SHEET1'!$A$2:$A$2000)/('SHEET2'!D2='SHEET1'!$D$2:$D$2000),'SHEET1'!$C$2:$C$2000)
you can use this formula :
=INDEX(Sheet1!C1:C2000;MATCH(1;INDEX((Sheet1!A1:A2000=Sheet2!A1)*(Sheet1!D1:D2000=Sheet2!D1);0;1);0))
so you can use more than one criteria in secend index like this:
=INDEX((criteria1)*(criteria2)*(criteria3);)
Related
Good day,
I'm trying to use V&hLookup to get my values but I'm not sure if I'm using the correct formula.
I'm working of 2 sets of data (sheet1 and sheet2). Sheet1 the data is vertical (e.g. unique identifiers and dates) and sheet2 the dates are horizonal and values below. Both sheets have unique identifiers Vertically.
Question: On sheet1, I need to look up the values from sheet2, if there is not values then the formula must look at the next available value after the start date? I got the values as examples on sheet1 as to what it should be
E.g.
Sheet1
Key
Dates
Values
12345
01/01/2020
120.00
678910
01/02/2020
150.00
789456
01/03/2020
110.00
Sheet2
Key
01/01/2020
01/02/2020
03/04/2020
12345
120.00
0.00
150.00
678910
0.00
120.50
130.00
789456
160.00
120.00
110.00
Thanks a million.
Edited answer: suggested solution using MATCH(search_value,match_range,1) in combination with INDEX gave wrong results.
The following should do:
=INDEX(Sheet2!$A$1:$D$4,
MATCH(A5,Sheet2!$A$1:$A$4,0),
MATCH(
MIN(IF(Sheet2!$B$1:$D$1>=B5,Sheet2!$B$1:$D$1,"")),
Sheet2!$A$1:$D$1,
0))
Enter with ctrl+shift+enter in older Excel versions.
The row is found matching the Key-value and the column is found by matching the column where the date value in Sheet2 headers greater than or equal to search date value.
And when using Tables:
=INDEX(Table3,
MATCH([#Key],Table3[Key],0),
MATCH(
MIN(IFERROR(IF(--Table3[#Headers]>=[#Dates],--Table3[#Headers]),9^9)),
--Table3[#Headers],
0))
Where I needed to workaround the date headers becoming text instead of number values by adding leading -- to the value/range.
I have 2 sheets in one excel file. I'd like to copy only the team column from sheet 2 to sheet 1. Both sheets have matching ID to relate to each other.
Sheet 1
id
name
address
team
123
Paul
1st street
456
Kyle
2nd Street
Sheet 2
id
name
team
123
Paul
CL
456
Kyle
BSM
And then sheet 1 will now look like this:
id
name
address
team
123
Paul
1st street
CL
456
Kyle
2nd Street
BSM
I don't know where to start. I know though that this can be done in excel, and you can do programming on it. I don't want to manually input it since it's more than a hundred records.
Okay so I am assuming all the headers are in first row. This can easily be done through Vlookup
=VLOOKUP(A2,Sheet2!A:C,3,FALSE)
Put this formula in column team in Sheet1. It will work.
Let me know if you need any further clarification.
I would like to look up a value in a range and return the value in the next row, but can't quite figure out how to do this. I especially would like to do this with formulas rather than VBA, and preferably with built-in formulas than custom (VBA) formulas, due to macro security issues.
I'm using Excel 2010. My workbook has two worksheets, "assessment" and "lookup". In lookup, I have lookup tables.
"lookup" looks something like:
Column A Column B Column C
1 Sales Engineering Manufacturing
2 Alice Bobbie Charlie
3 Dawn Edgar Frank
4 George Holly Isabel
In "assessment," I have some some drop downs from which users select one name from each column in "lookup." Based on some other criteria, I then rank these and create a new, sorted list (using INDEX() and MATCH()) that produce the selected name and corresponding column name a new sort order
Column A Column B
10 Engineering Edgar
11 Sales Alice
What I'd like is to return the name from the next row.
Column C
10 Holly
11 Dawn
But I'm having real trouble figuring out how to get there.
Assuming lookups is located at B2:D5 (change as required) and the result data is at F2:H3 (change as required) enter this formula in cell H2 then copy down.
=INDEX(
INDEX($B$2:$D$5,0,MATCH($F2,$B$2:$D$2,0)),
1+MATCH($G2,
INDEX($B$2:$D$5,0,MATCH($F2,$B$2:$D$2,0)),0))
I have an excel workbook with 2 sheets.
Sheet 4 and Sheet 5:
Sheet 4 has the following columns:
type model name year
U acura jane 1998
D honda peter 2002
U bmz fred 1993
Sheet 5 also has the same columns but with an additional column sales.
type model name sales
U acura jane 2.3
D honda peter 3.8
U bmz fred 19
IN both the sheets, I created an additional column called "key" concatenating type-model-name (A2&B2&C2)
type model name year key
U acura jane 1998 Dacurajane
D honda peter 2002 Dhondapeter
U bmz fred 1993 Dbmzfred
To get the sales in Sheet1, I am giving the following vlookup.
=VLOOKUP(E2|Sheet5!A2:F4|5|FALSE)
I looked at other similar answers, trimmed the columns and did what the recommendations were, but it still returns #N/A
Can anyone point out what my mistake it?
Thanks In advance.
Use INDEX/MATCH
=INDEX(Sheet5!D:D, MATCH(E2, Sheet5!A:A&Sheet5!B:B&Sheet5!C:C, 0))
Enter with Ctrl-Shift-Enter
Also I am assuming that the sales is in column D of Sheet5. If different, put the appropriate column in as first parameter to the INDEX function.
Also please consider using restricted range references in the match function, instead of full column references - for speed & efficiency.
on cell E1 you will have KEY on cell E2 you will place =CONCATENATE(A2,B2,C2,D2) Combines contents above into a phrase "DFocusManuel2016". That should work for the combine part just paste that and drag down as desired on E2.
You can cover the rest of the cell population by simply assigning links to the cells so on cell A2,B2,C2 and D1 you will have =SHEETNAME!Y10 which Y10 corresponds to the source cell and Sheet name to the source sheet.
I have two columns of data in Excel. Column A is an interaction date, and column B is a name. I'm looking to devise a way to identify repeat contacts by the same name that occur within 1 day of each other. eg:
Date Name
2016/01/01 John Wayne
2016/01/01 Paul Friesen
2016/01/01 John Wayne
2016/01/01 Alex Roschenko
2016/01/02 Paul Friesen
2016/01/02 Peter Mansbridge
2016/01/02 Jake Snake
2016/01/03 Paul Feig
2016/01/03 John Wayne
Using only this sample data, the result I would be looking for is 2 (John Wayne and Paul Friesen both repeated in =< 1 day.
I'm not sure if Excel or Access are the better tool to use for this, but I'm more experience in Excel, I just haven't been able to come up with a formula...
Use a helper column.
In a blank column put the following in row 2:
=SUM(COUNTIFS(B:B,B2,A:A,A2+{-1,0,1}))>1
This will return a column of TRUE/FALSE
Then referencing the helper column we use the following array formula:
=SUM(IF($C$2:$C$10,1/COUNTIFS($B$2:$B$10,$B$2:$B$10,$C$2:$C$10,TRUE)))
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter when exiting edit mode instead of Enter. If done properly then Excel will put {} around the formula.
This formula counts the unique names that have TRUE in the helper column. So no matter how many times the name has TRUE next to it, it will only be counted once.