Home > database >  How can I duplicate rows of data "x" times where x is variable in google sheet?
How can I duplicate rows of data "x" times where x is variable in google sheet?

Time:04-11

I have these two columns in Google sheet:

Region Traffic
Japan Online
Korea Offline
Ghana Mix

I would like a way to use an automatic formula that creates this:

Region Traffic
Japan Online
Japan Offline
Japan Mix
Korea Online
Korea Offline
Korea Mix
Ghana Online
Ghana Offline
Ghana Mix

Any idea on how to do this in google sheets? :)

CodePudding user response:

try:

=INDEX(TRIM(SPLIT(FLATTEN(SPLIT(REPT(QUERY(
 FILTER({A2:A&"♠"&B2:B&"♣"}, A2:A<>""),,9^9), D1), "♣")), "♠")))

enter image description here

or:

=INDEX(SPLIT(FLATTEN(FILTER(A2:A, A2:A<>"")&"♦"&TRANSPOSE(FILTER(B2:B, B2:B<>""))), "♦"))

enter image description here

  • Related