Solved

merging data from 2 sheets based on a join value

Posted on 2016-09-22
4
28 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 31

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 28

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 13

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
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…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now