Solved

merging data from 2 sheets based on a join value

Posted on 2016-09-22
4
43 Views
Last Modified: 2016-10-20
I have an xlsx with 2 sheets, in the first sheet, customer data is in a row by row format, i.e

Custreference forename surname address 1 address 2 etc
12345 EE user 123 street london

At the end of sheet 1 are 3 blank columns (phone, mobile, email), and I need to populate them with data from sheet 2

In sheet 2 are 3 columns

Custreference type value
e.g.
12345 phone 999888
12345 mobile 777666
12345 email op@ee.com

The only way to join the records is via the customer reference field which is on both sheets. What i need really is 3 formulas in the 3 columns in sheet 1, to check all values of sheet 2, and for example in the phone column, compare all  the rows in sheet 2, where type = phone, and reference matches from both sheets, to populate the phone column with the value for that reference in sheet 2.

Likewise for the mobile column, check all rows in sheet 2 where reference matches, and type = mobile, populate the mobile column in sheet 1 with the mobile value in sheet 2 for that reference.
0
Comment
Question by:pma111
4 Comments
 
LVL 32

Accepted Solution

by:
Rob Henson earned 250 total points
ID: 41810529
In sheet 2 use the CONCATENATE function to combine the cust ref with type:

=CONCATENATE(A2,"_",B2)  gives "12345_phone"

Then in sheet 1 use a vlookup on a similarly concatenated value:

=VLOOKUP(CONCATENATE($A2,"_",F$1),Sheet2!$A:$D,4,False)   where A2 is CustRef and F1 is type header

If you upload a sample, it can be put in place.

Thanks
Rob H
0
 
LVL 29

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41810533
Please upload a sample workbook to work with.
0
 
LVL 27

Assisted Solution

by:Glenn Ray
Glenn Ray earned 250 total points
ID: 41811563
Rob's recommendation is the easiest - add a concatenated Key Field that helps identify the records.  You can also combine the fields like so:
Key Field:  =A2&B2

Adding a delimiting character (like an underscore) helps readability, but isn't necessary to make the VLOOKUP work.

Usually these are set up as temporary columns and are quick and relatively non-invasive on your data.  However, if you really want to retrieve the data using multiple variables, there is a more-complex method that doesn't involve any table manipulation.

Given your data construction in Sheet2, the values can be retrieved with this formulas:
=IFERROR(INDEX(Data!$C$2:$C$1000,SUMPRODUCT(--($A2=Data!$A$2:$A$1000),--(I$1=Data!$B$2:$B$1000),ROW($2:$1000))-1),"")

This presumes that:
1) the Custreference is in column A (like in your example)
2) the columns for "phone", "mobile", and "email" are in columns I, J, and K in Sheet1
3) the column headers in I1, J1, and K1 are "phone", "mobile", and "email"
4) there is no more than 1000 rows of data in Sheet2

The Sheet2 data can be in any order and doesn't have to have values for all Custreference codes. The formula is the same in all three columns; just copy across and down.  See the example workbook.
EE-Q_28971612.xlsx
0
 
LVL 14

Expert Comment

by:frankhelk
ID: 41851709
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Split:
-- Rob Henson (https:#a41810529)
-- Glenn Ray (https:#a41811563)


If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

frankhelk
Experts-Exchange Cleanup Volunteer
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvieā€¦
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calculā€¦
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question