'How to get a specific number of cells using an array formula in Google Sheets

I want to pre-process my data like the Result section of the attached image before flattening and using it.

I want to write an array formula in the cells marked in blue. How do I get results?

enter image description here



Solution 1:[1]

try:

=ARRAYFORMULA(IF(COLUMN(A2:D5)<=F2:F5; A2:D5; ))

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 player0