0

please, I don't know what to do. I want to get (create) rows in Google Sheets from other row by number in this row. From other tab or diferent sheet.

For example: Create the second table from the first table. I tried Query and Sequence, but I guess I don't have that skill. Formula ideally based on "query".

1)

Code PCS Data
Product1 2 DataA
Product2 1 DataB
Product3 0 DataC
Product4 4 DataD

2)

Code PCS Data
Product1 2 DataA
Product1 2 DataA
Product2 1 DataB
Product4 4 DataD
Product4 4 DataD
Product4 4 DataD
Product4 4 DataD
TheMaster
  • 45,448
  • 6
  • 62
  • 85
  • Does this answer your question? [Repeat whole row N times based on column value in Google Sheets](https://stackoverflow.com/questions/73880042/repeat-whole-row-n-times-based-on-column-value-in-google-sheets) – TheMaster Oct 31 '22 at 11:40

2 Answers2

0

Try this:

=index(query({A1,B1,C1;
iferror(flatten(if(B2:B<>"",split(rept(A2:A&"|",B2:B),"|"),)),),
iferror(flatten(if(B2:B<>"",split(rept(B2:B&"|",B2:B),"|"),)),),
iferror(flatten(if(B2:B<>"",split(rept(C2:C&"|",B2:B),"|"),)),)
},"where Col1 is not null",1))

enter image description here

Aresvik
  • 4,484
  • 1
  • 5
  • 18
0

use:

=INDEX(QUERY(SPLIT(FLATTEN(SPLIT(REPT("‍"&FLATTEN(QUERY(TRANSPOSE(
 IF(B2:B>0; A2:C&"​"; ));;9^9)); B2:B); "‍")); "​"); "where Col3 is not null"; ))

enter image description here

player0
  • 124,011
  • 12
  • 67
  • 124