Home > Blockchain >  Google sheets - How get multiple rows from one row by number
Google sheets - How get multiple rows from one row by number

Time:10-31

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

CodePudding user response:

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

CodePudding user response:

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

  • Related