How to populate rows based on the number required in google sheet?

Viewed 30

enter image description here

Hi all,

I want to use a formula to duplicate the department name based on the number of employee in the department. For example. there are 2 employee in Finance department, so the formula will duplicate 2 Finance in column E, and there are 7 employee in Product department, then the formula will duplicate 7 Product in column E below Finance. Column E is the expected output that I want to achieve. Not sure whether it is possible to achieve or not. Any help or advise will be greatly appreciated!

2 Answers

use:

=INDEX(FLATTEN(TRIM(SPLIT(QUERY(REPT(B3:B&"♦",C3:C),,9^9),"♦"))))

Try

=ARRAYFORMULA(TRIM(TRANSPOSE(SPLIT(QUERY( REPT(B3:B&"♥", C3:C), ,9^9), "♥"))))

enter image description here

Related