Home > Software design >  Excel MERGE two tables
Excel MERGE two tables

Time:06-06

I have SET 1

CLASS Student TEST SCORE
A 1 1 46
A 1 2 50
A 1 3 45
A 2 1 45
A 2 2 47
A 2 3 31
A 3 1 34
A 3 2 45
B 1 1 36
B 2 1 31
B 2 2 41
B 3 1 50
C 1 1 42
C 3 1 31

and SET 2

CLASS SIZE YEARS
A 39 7
B 20 12
C 31 6

and wish to COMBINE to make SET 3

CLASS STUDENT TEST SCORE SIZE YEARS
A 1 1 46 39 7
A 1 2 50 39 7
A 1 3 45 39 7
A 2 1 45 39 7
A 2 2 47 39 7
A 2 3 31 39 7
A 3 1 34 39 7
A 3 2 45 39 7
B 1 1 36 20 12
B 2 1 31 20 12
B 2 2 41 20 12
B 3 1 50 20 12
C 1 1 42 31 6
C 3 1 31 31 6

so basically add the SIZE and YEARS columns from SET 2 and merge on CLASS onto SET 1. In excel how you can do this? I need to match on CLASS

CodePudding user response:

If you have Set 1 on the top left of a worksheet "Set1" and Set 2 on the top left of a worksheet "Set2", then you can use the formula =VLOOKUP(A2;'Set2'!$A$2:$C$4;2;FALSE), where $A$2:$C$4 is the range of Set2, and A2 is the class value from Set1, which is what is used to do the lookup in Set2. The next argument, 2, means to take the second row from Set2, and the FALSE at the end means that you only want exact matches on the CLASS. You can do auto-fill with this formula, and do similar steps for the years. If you look up the help for VLOOKUP within Excel, that should help you to understand how it works.

CodePudding user response:

Your first set of data is essentially your primary set of data that you just want to add attribute columns to. I built enter image description here

  • Related