1

I have a table where it needs to be repeated whenever there is a value 1 in A column D2 number of times as shown

I have tried with =QUERY(A1:D7,"select C,B where A=1")

https://docs.google.com/spreadsheets/d/1B4261XqXBbAQs8vHAyg40TeCvo8qFxZ9AIPezmN2yjc/copy

enter image description here

Prefer to have a single long formula that can accomplish.

player0
  • 124,011
  • 12
  • 67
  • 124
Code Guy
  • 3,059
  • 2
  • 30
  • 74
  • Your question can be greatly improved if you add input table and expected output table to the question. [Tables](https://webapps.stackexchange.com/a/161855/) are a better alternative than spreadsheets to show your data structure. If you share spreadsheets, make sure to also add images of your sheet to avoid closure of your question, as questions here must be [self](https://meta.stackoverflow.com/a/260455) [contained](https://meta.stackexchange.com/a/149892). [Your email address can also be accessed by the public](https://meta.stackoverflow.com/questions/394304/), when you share Google files. – TheMaster Sep 29 '22 at 17:54
  • 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 Sep 29 '22 at 18:03
  • 1
    Does this answer your question? https://stackoverflow.com/questions/70160891/how-to-repeat-a-data-set-several-columns-x-times-in-google-sheets – TheMaster Sep 29 '22 at 18:05

1 Answers1

1

use:

=ARRAYFORMULA(SORT(SPLIT(FLATTEN(FILTER(C2:C6&"×"&
 SEQUENCE(1, D2)&"×"&B2:B6*SEQUENCE(1, D2), A2:A6=1)), "×"), 2, 1))

enter image description here

player0
  • 124,011
  • 12
  • 67
  • 124