Home > other >  How do you convert a Google Sheet to a different layout? Combine multiple rows that have the same da
How do you convert a Google Sheet to a different layout? Combine multiple rows that have the same da

Time:11-24

Is it possible to convert data found in Sheet #1 to the format found in Sheet #2


Sheet1 - Current dataset.

# A B C D E F G H I
1 - Employee ID Class ID
2 - 555555 - - - - - - Class004
3 - 888888 - - - - - - Class004
4 - 777777 - - - - - - Class004
5 - 333333 - - - - - - Class004
6 - 666666 - - - - - - Class002
7 - 111111 - - - - - - Class002
8 - 222222 - - - - - - Class002
9 - 222222 - - - - - - Class009

Sheet2 - Expected Outcome using formulas.

# A B C
1 - Class ID Employee ID's
2 - Class004 555555 888888 777777 333333
3 - Class002 666666 111111 222222
4 - Class009 222222
  • Column B contains a unique class ID for each row.

    • A class ID may have 4-20 characters, it may look like: "Class001", "CID001", "V001", or something else (because whoever created this data could not decide on a unified format lol)

    • Currently I am using this formula. Is there a better formula? =UNIQUE(Sheet1!I2:I) placed in Sheet2!B2.

  • Column C contains all the employee ID's in a single row (separated by a space) who participated in that particular class.

    • Some employees have participated in multiple classes (example Employee 222222 was in Class002 and Class009) so the same Employee ID can be found in multiple rows.
    • I tried using =ARRAYFORMULA(VLOOKUP(Sheet2!B2:B,Sheet1!{I2:I,B2:B},2,0)) in Sheet2!C2 but this will only return the first match. Perhaps there is a way to use vlookup to return an array of all Employee ID's matching the Class ID#, transpose them, then concat them? What do you suggest?

Thanks for your help! :)

CodePudding user response:

Try:

=JOIN(" ",FILTER(Sheet1!B:B,Sheet1!I:I=B2))

Then drag it down for the other Classes

  • Related