I have rows with start and end date. I need to repeat each row N times and increment new date column by one. N = the number of days between the start date and en date
My table:
Column A | Start date | End date |
---|---|---|
A | 10/09/2022 | 12/09/2022 |
B | 15/09/2022 | 16/09/2022 |
C | 08/09/2022 | 12/09/2022 |
The result I'd like to generate automatically (new row will often be added):
Column A | Start date | End date | Date |
---|---|---|---|
A | 10/09/2022 | 12/09/2022 | 10/09/2022 |
A | 10/09/2022 | 12/09/2022 | 11/09/2022 |
A | 10/09/2022 | 12/09/2022 | 12/09/2022 |
B | 15/09/2022 | 16/09/2022 | 15/09/2022 |
B | 15/09/2022 | 16/09/2022 | 16/09/2022 |
C | 08/09/2022 | 12/09/2022 | 08/09/2022 |
C | 08/09/2022 | 12/09/2022 | 09/09/2022 |
C | 08/09/2022 | 12/09/2022 | 10/09/2022 |
C | 08/09/2022 | 12/09/2022 | 11/09/2022 |
C | 08/09/2022 | 12/09/2022 | 12/09/2022 |
I hope my need is clear.
Thanks,
CodePudding user response:
try:
=QUERY(ARRAYFORMULA(SPLIT(FLATTEN(A2:A&"|"&B2:B&"|"&C2:C&"|"&MAP(B2:B,C2:C,LAMBDA(bx,cx,if(bx="",,TRANSPOSE(SEQUENCE(DATEDIF(bx,cx,"d") 1,1,bx,1)))))),"|")),"Select * Where Col4 IS NOT NULL")
-