Repeat blocks of columns and row N times based on the number of columns in Google Sheets.

huangapple go评论63阅读模式
英文:

Repeat blocks of columns and row N times based of N number of Columns in google sheet

问题

I am currently working in Google Sheets and would like to create transpose specific columns and repeat on all rows in the table. For example:

ID Another header Desc Item1 Item2 Item3 Item4 Item5
1 AA BBB 0 0 0 0 0
2 BB CCC 0 1 0 0 0

I would like to get a result as:

ID Another header Desc Item
1 AA BBB Item1
1 AA BBB Item2
1 AA BBB Item3
1 AA BBB Item4
2 BB CCC Item1
2 BB CCC Item2
2 BB CCC Item3
2 BB CCC Item4

I tried using a Lambda function LAMBDA(x, y, REDUCE(x, SEQUENCE(y-1), LAMBDA(a, b, IF(b, {a; x})))) (range, 4), but this only helped me replicate the rows. I would appreciate it if anyone could help me with this. Thank you!

英文:

I am currently working in Google sheet and would like to create transpose specific columns and repeat on all rows in the table, For example

ID Another header Desc Item1 Item2 Item3 Item4 Item5
1 AA BBB 0 0 0 0 0
2 BB CCC 0 1 0 0 0

I would like to get a result as

ID Another header Desc Item
1 AA BBB Item1
1 AA BBB Item2
1 AA BBB Item3
1 AA BBB Item4
2 BB CCC Item1
2 BB CCC Item2
2 BB CCC Item3
2 BB CCC Item4

I tried using Lamba function LAMBDA(x, y, REDUCE(x, SEQUENCE(y-1), LAMBDA(a, b, IF(b, {a; x})))) (range, 4) but this only helped me to replicated the rows. I would appreciate if anyone could help me with this. Thank you !

答案1

得分: 1

Your formatting for the input table got a bit mangled but I think I was able to determine the layout. If your input table begins at A1 in the sheet you can try the following to generate the desired output:
={{A1:C1,"项目"};arrayformula(split(tocol(A2:A3&"|"&B2:B3&"|"&C2:C3&"|"&D1:H1),"|"))}

英文:

Your formatting for the input table got a bit mangled but I think I was able to determine the layout. If your input table begins at A1 in the sheet you can try the following to generate the desired output:

={{A1:C1,"Item"};arrayformula(split(tocol(A2:A3&"|"&B2:B3&"|"&C2:C3&"|"&D1:H1),"|"))}

</details>



huangapple
  • 本文由 发表于 2023年5月22日 19:59:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/76305951.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定