Search code examples
sqlgoogle-sheetsfirst-normal-form

Query for normalized Google Sheet table


I want to normalize following table in Google Sheet:

Process Tool A Tool B
Process 1 Tool 1 Tool 2
Process 2 Tool 1
Process 3 Tool 2 Tool 3

into the following 1NF table:

Process Tool A Tool B
Process 1 Tool 1
Process 1 Tool 2
Process 2 Tool 1
Process 3 Tool 2
Process 3 Tool 3

There are various options (Google Sheets QUERY() function, etc.).


Solution

  • You may try:

    =reduce(A1:B1,B2:C,lambda(a,c,vstack(a,if(c="",tocol(,1),{index(A:A,row(c)),c}))))
    

    enter image description here