google-sheetsgoogle-sheets-formulagoogle-query-languagepandas-explodefirst-normal-form

How to create a formula that will repeat a range by splitting one column and joining with the other column?


I have 2 columns, first name and surname. I want to split a cell that contains multiple values and then combine it with the cell on the right. I have no idea how to do this using a formula, please help.

Before:

First Name Surname
John,Jane,Mary Fish
Albert,Steven,Alice Smith

Expected Result:

First Name Surname
John Fish
Jane Fish
Mary Fish
Albert Smith
Steven Smith
Alice Smith

Solution

  • use:

    =INDEX(QUERY(SPLIT(FLATTEN(IF(IFERROR(
     SPLIT(A1:A, ","))="",,SPLIT(A1:A, ",")&"​"&B1:B)), "​"), 
     "where Col2 is not null", ))
    

    enter image description here