Search code examples
google-sheetstransposegoogle-sheets-formulaarray-formulasgoogle-sheets-query

Comma separated list into matched columns pairings


I thought I was a decent Sheets jockey, but here's a toughie. I'd like to turn the left into the right using just a formula

snap

Sample also at: https://docs.google.com/spreadsheets/d/1JgDZOV_K7SbOrCb27Z5K2XUBcrtq99GTCa3-BM2pOD0

The closest I found was this (Separating Comma List into Cells with Formula) but it doesn't also do the matching.


Solution

  • alternative by @Matt:King:

    =ARRAYFORMULA(QUERY(VLOOKUP(SEQUENCE(COUNTA(A2:A)*
     COLUMNS(SPLIT(B2:B, ",")), 1, 0)/ COLUMNS(SPLIT(B2:B, ","))+2,
     {ROW(A:A), A:A, TRIM(SPLIT(B:B, ","))}, MOD(SEQUENCE(COUNTA(A2:A)*
     COLUMNS(SPLIT(B2:B, ",")), 1, 0), COLUMNS(SPLIT(B2:B, ",")))*{0, 1}+{2, 3}),
     "where Col2 is not NULL"))
    

    0