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 |
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.).
Share Improve this question edited Feb 4 at 12:19 philipxy 15.2k6 gold badges43 silver badges97 bronze badges asked Feb 2 at 20:27 SaxSax 112 bronze badges3 Answers
Reset to default 1Use wraprows()
, like this:
=let(
get_, lambda(a, filter(hstack(A2:A, a), len(a))),
wraprows(tocol(hstack(get_(B2:B), get_(C2:C)), 3), 2)
)
See let(), lambda(), hstack(), filter(), wraprows(), and tocol().
Try this Alternative approach
=QUERY(ARRAYFORMULA(SPLIT(FILTER(FLATTEN(A2:A&"|"&B2:C), FLATTEN(B2:C)<>""), "|")),"SELECT Col1, Col2 LABEL Col1 'Process', Col2 'Tool A'",0)
Expected Output
Process | Tool A |
---|---|
Process 1 | Tool 1 |
Process 1 | Tool 2 |
Process 2 | Tool 1 |
Process 3 | Tool 2 |
Process 3 | Tool 3 |
References
QUERY()
FLATTEN()
SPLIT()
You may try:
=reduce(A1:B1,B2:C,lambda(a,c,vstack(a,if(c="",tocol(,1),{index(A:A,row(c)),c}))))
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745257855a4619062.html
评论列表(0条)