sql - Query for normalized Google Sheet table - Stack Overflow

I want to normalize following table in Google Sheet:ProcessTool ATool BProcess 1Tool 1Tool 2Process

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 badges
Add a comment  | 

3 Answers 3

Reset to default 1

Use 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

相关推荐

  • sql - Query for normalized Google Sheet table - Stack Overflow

    I want to normalize following table in Google Sheet:ProcessTool ATool BProcess 1Tool 1Tool 2Process

    4小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信