Google-sheets – Joining Two Tables and Merging Cells

google sheets

Say I have list of users and their info. Each user can have multiple accounts, and the "paid" status of each of those accounts may be "no" or "yes". A user may have one or two paid accounts.

My first sheet looks like this (fake data):

enter image description here

This is my second sheet:

enter image description here

I want to join both sheets so they look like this (with merged cells):

enter image description here

Here I have listed only two accounts per user, but there may be more accounts or less accounts than that.

How do I accomplish this?

Best Answer

I would suggest using dget in the first sheet, if the number of users is defined, and doesn't grow automatically.

Assuming the second sheet is Sheet2, I would add 2 columns to the first sheet.

The first column would have cells with the formula (changing the cells accordingly, with copy and paste):

=dget(Sheet2!$A:$C,"PAID ACCOUNT",{"USER ID";$A2})

The second column would have cells with the formula (changing the cells accordingly, with copy and paste):

=dget(Sheet2!$A:$C,"ACCOUNT ID",{"USER ID";$A2})

You could also try a more direct approach, by using cell references in the "field" section, such as:

=dget(Sheet2!$A:$C,Sheet2!B$1,{"USER ID";$A2})

After this, you would only need to copy and paste the formula in all the cells that require importing.

If the list grows or is fed from a form, then this solution would not apply.