I suggest vlookup
in combination with filter
. Here is an example:
=arrayformula(vlookup(filter(Master!D2:D, Master!E2:E="o"), {Data1!B:B, Data1!A:E}, {2,3,4,5,6}, false))
Step by step:
filter(Master!D2:D, Master!E2:E="o")
takes the Id s from Master column D where column E is marked "o".
{Data1!B:B, Data1!A:E}
prepares an array for lookup. This is only needed because your Id is not in the first column of the range; so an array has to be created with Id in the first column.
vlookup
searches for the Ids returned by filter and returns the corresponding columns A-E from Data1
arrayformula
ensures this all happens at once, no need to paste the formula row by row.
Older post, but I wrote a single-cell array formula that accomplishes this task and placed it into your editable sheet, in a new sheet I created for the purpose (Sheet2).
Headers are manually entered in Sheet2!A1:E1.
The following array formula is entered into Sheet2!A2:
=ArrayFormula(IF(ROW(Sheet1!A2:A)>COUNTA(Sheet1!A2:A)*18+1,"",{VLOOKUP(Sheet1!A$1,TRANSPOSE(QUERY({Sheet1!A:AM})),INT((ROW(Sheet1!A2:A)-2)/18)+2,FALSE),VLOOKUP(VLOOKUP(Sheet1!A$1,TRANSPOSE(QUERY({Sheet1!A:AM})),INT((ROW(Sheet1!A2:A)-2)/18)+2,FALSE),Sheet1!A2:AM,{2,3},FALSE),VLOOKUP(VLOOKUP(Sheet1!A$1,TRANSPOSE(QUERY({Sheet1!A:AM})),INT((ROW(Sheet1!A2:A)-2)/18)+2,FALSE),Sheet1!A2:AM,MOD(ROW(Sheet1!A2:A)-2,18)+4,FALSE),VLOOKUP(VLOOKUP(Sheet1!A$1,TRANSPOSE(QUERY({Sheet1!A:AM})),INT((ROW(Sheet1!A2:A)-2)/18)+2,FALSE),Sheet1!A2:AM,MOD(ROW(Sheet1!A2:A)-2,18)+22,FALSE)}))
Best Answer